0

On manually saving products on the admin page, I have tested the catalog_product_save_after event and my observer can successfully catch the event. So this event exists in Magento 2, however I can not find this event in any cheat sheets like: https://cyrillschumacher.com/magento-2.1-list-of-all-dispatched-events/

On the other hand, I can find controller_action_catalog_product_save_entity_after in the list.

So here is my question: why catalog_product_save_after event is not listed? What is the difference between catalog_product_save_after and controller_action_catalog_product_save_entity_after?

2

Magento 2.1.7 CE:

1) controller_action_catalog_product_save_entity_after is trigger when saving product in Admin.

2) Most Model entities derive from \Magento\Framework\Model\AbstractModel. In this abstract class, we can find some events. For example:

/**
 * Processing object after save data
 *
 * @return $this
 */
public function afterSave()
{
    ......
    $this->_eventManager->dispatch($this->_eventPrefix . '_save_after', $this->_getEventData());
    ......
}

As we can see, some model events names will be trigger. The name of event will be added the prefix $this->_eventPrefixof model. We can define the event prefix in the model.

vendor/magento/module-catalog/Model/Product.php

/**
 * @var string
 */
protected $_eventPrefix = 'catalog_product';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.