$mapping =
[];
foreach ($events as $event) { $config =
json_decode((string) $event['config'
], true, 512, \JSON_THROW_ON_ERROR
);
if (!
isset($config['mail_template_type_id'
])) { continue;
} $mapping[] =
['event_name' =>
$event['event_name'
], 'typeId' =>
$config['mail_template_type_id'
]];
} $mails =
$this->
fetchMails($connection,
array_column($mapping, 'typeId'
));
$mails =
$this->
map($mapping,
$mails);
$this->
insertMails($connection,
$mails);
// generate entries for order state mails
$ids =
$this->
getTypeIds($connection,
[ 'order_delivery.state.cancelled',
'order_delivery.state.returned',
'order_delivery.state.returned_partially',
'order_delivery.state.shipped',