/ Published in: PHP
http://codemagento.com/2011/04/observers-and-dispatching-events/
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
config.xml <global> <events> <customer_address_save_before> <observers> <yourmodule> <type>singleton</type> <class>yourmodule/observer</class> <method>customer_address_save_before</method> </yourmodule> </observers> </customer_address_save_before> <customer_address_save_after> <observers> <yourmodule> <type>singleton</type> <class>yourmodule/observer</class> <method>customer_address_save_after</method> </yourmodule> </observers> </customer_address_save_after> <catalog_product_save_before> <observers> <yourmodule> <type>singleton</type> <class>yourmodule/observer</class> <method>catalog_product_save_before</method> </yourmodule> </observers> </catalog_product_save_before> <catalog_product_save_after> <observers> <yourmodule> <type>singleton</type> <class>yourmodule/observer</class> <method>catalog_product_save_after</method> </yourmodule> </observers> </catalog_product_save_after> </events> </global> Observer.php class YourNamespace_YourModule_Model_Observer { public function customer_address_save_before($observer) { $address = $observer->getCustomerAddress(); //echo "<pre>"; print_r($address->getData()); exit; // do something here } public function customer_address_save_after($observer) { $address = $observer->getCustomerAddress(); //echo "<pre>"; print_r($address->getData()); exit; // do something here } public function catalog_product_save_before($observer) { $product = $observer->getProduct(); //echo "<pre>"; print_r($product->getData()); exit; // do something here } public function catalog_product_save_after($observer) { $product = $observer->getProduct(); //echo "<pre>"; print_r($product->getData()); exit; // do something here } }
URL: http://blog.chapagain.com.np/magento-event-observer-with-save-before-and-save-after/