i want observer event for the customer delete action in magento. There is any observer is there for that or i create custom observer. I Search a lot but not find the observer for the customer delete action in admin grid area
1
votes
2 Answers
6
votes
The customer model extends Mage_Core_Model_Abstract
which has a _beforeDelete()
and _afterDelete()
methods. Each delete method fires 2 dispatch events:
_beforeDelete():
Mage::dispatchEvent('model_delete_before', array('object'=>$this));
Mage::dispatchEvent($this->_eventPrefix.'_delete_before', $this->_getEventData());
_afterDelete():
Mage::dispatchEvent('model_delete_after', array('object'=>$this));
Mage::dispatchEvent($this->_eventPrefix.'_delete_after', $this->_getEventData());
Too hook into these events, just set the config.xml
of your module to fire methods when the customer model is in the process of being deleted. The customer model's $_eventPrefix
value is 'customer', so the following should fire MyModule_Model_Observer:: onCustomerDeleteDoThis()
right before the customer object is deleted:
<events>
<customer_delete_before>
<observers>
<my_module_delete_customer>
<class>mymodule/observer</class>
<method>onCustomerDeleteDoThis</method>
</my_module_delete_customer >
</observers>
</customer_delete_before>
</events>