How to perform event action for Catalog Product after delete completed?

You can perform event action to successfully Product deleted in Magento 2 by the catalog event name catalog_product_delete_after_done. This is the perfect event for product delete observer.

If Magento is sync with a third party ERP system and wants to sync product data between two platforms, if product deleted in Magento and want to delete a product from the ERP, You can perform this action using Magento native Event catalog_product_delete_after_done.

You can see the native Magento event declaration from the Model file, Magento/Catalog/Model/ResourceModel/Product with method name delete($object).

Create an Event in adminhtml area by events.xml file,
app/code/Jesadiya/Erp/etc/adminhtml/events.xml

Create an Observer file,
app/code/Jesadiya/Erp/Observer\ProcessProductAfterDeleteEventObserver.php

In Observer file, You got the product id which was the latest product delete from the Magento.

This event is used to remove product-specific data once the product is deleted from the Magento instance.

You can explore the real-time example from the Review Module with admin events in native Magento.

You can also interested in seeing A Complete List of all events in Magento 2.

Leave a Reply