public static function getSubscribedEvents(): array
{ return [ ImportExportAfterImportRecordEvent::
class => 'onAfterImportRecord',
];
} public function onAfterImportRecord(ImportExportAfterImportRecordEvent
$event): void
{ $row =
$event->
getRow();
$entityName =
$event->
getConfig()->
get('sourceEntity'
);
$entityWrittenEvents =
$event->
getResult()->
getEvents();
if ($entityName !== ProductDefinition::ENTITY_NAME ||
empty($row['variants'
]) || !
$entityWrittenEvents) { return;
} $variants =
$this->
parseVariantString($row['variants'
]);
$entityWrittenEvent =
$entityWrittenEvents->
filter(fn ($event) =>
$event instanceof EntityWrittenEvent &&
$event->
getEntityName() === ProductDefinition::ENTITY_NAME
)->
first();
if (!
$entityWrittenEvent instanceof EntityWrittenEvent
) { return;
}