Magento – Where is ‘catalog_product_save_before’ Dispatched?

event-observer

I'm struggling to find the dispatch event for thecatalog_product_save_before.

I've done a find of my entire project on the following search term: catalog_product_save_before. It's only found in 3rd party modules.

I'm looking to utilise this event, but first I'd like to inspect the code around the dispatcher to ensure I'm doing it in the correct area.

Events are dispatched as follows:

Mage::dispatchEvent('catalog_product_save_before', $data_array);
// Assuming in this case that $data_array is a qualified array

This appears nowhere in the core, which is puzzling. Is it perhaps defined in a different way?

Best Answer

The event is dispatched in Mage_Core_Model_Abstract::_beforeSave.
It is this line:

Mage::dispatchEvent($this->_eventPrefix.'_save_before', $this->_getEventData());

The product model class is a child class of Mage_Core_Model_Abstract and the _eventPrefix member is catalog_product for the product model.