In Magento 2 the event catalog_product_save_after is triggered during import of products from csv file?
Thanks in advanced for any response.
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityIn Magento 2 the event catalog_product_save_after is triggered during import of products from csv file?
Thanks in advanced for any response.
If you go to CatalogImportExport/Model/Import/Product.php
and check _saveProducts()
function you will see at the end they are dispatching catalog_product_import_bunch_save_after
this event. May be this is getting called.
controller_action_catalog_product_save_entity_after
not catalog_product_save_after
. Its a magento1 event not magento2.
Apr 12, 2017 at 14:11
catalog_product_save_after
this event dispatched.
Apr 12, 2017 at 14:53
As I found it will trigger on entity create or update and staging update or create scenarios.
Line 123 - Magento\Framework\EntityManager\Operation\Create
Line 110 - Magento\Framework\EntityManager\Operation\Update
public function execute($entity, $arguments = [])
{
$entityType = $this->typeResolver->resolve($entity);
$metadata = $this->metadataPool->getMetadata($entityType);
$connection = $this->resourceConnection->getConnectionByName($metadata->getEntityConnectionName());
$connection->beginTransaction();
try {
$this->eventManager->dispatch(
'entity_manager_save_before',
[
'entity_type' => $entityType,
'entity' => $entity
]
);
$this->eventManager->dispatchEntityEvent($entityType, 'save_before', ['entity' => $entity]);
$entity = $this->getSequenceApplier()->apply($entity);
$entity = $this->createMain->execute($entity, $arguments);
$entity = $this->createAttributes->execute($entity, $arguments);
$entity = $this->createExtensions->execute($entity, $arguments);
$this->eventManager->dispatchEntityEvent($entityType, 'save_after', ['entity' => $entity]);
$this->eventManager->dispatch(
'entity_manager_save_after',
[
'entity_type' => $entityType,
'entity' => $entity
]
);
$connection->commit();
} catch (DuplicateException $e) {
$connection->rollBack();
throw new AlreadyExistsException(new Phrase('Unique constraint violation found'), $e);
} catch (\Exception $e) {
$connection->rollBack();
throw $e;
}
return $entity;
}
Cheers!
controller_action_catalog_product_save_entity_after
? or i think thiscatalog_product_import_bunch_save_after
catalog_product_save_after
event exists in Magento2.