Magento Forum

Event dispatch not working for me
 
srinigenie
Guru
 
Avatar
Total Posts:  539
Joined:  2008-02-04
 

Hi all,

Magento ver. 0.8.17240

I am plugging in some customizations and thought I could use the Events provided by Magento. I wanted to code an observer to the event ‘catalog_product_save_after’ and am finding that my observer doesnot seem to be called on the event. The following threads were used to code the observer.

http://www.magentocommerce.com/boards/viewthread/3459/
http://www.magentocommerce.com/boards/viewthread/3114

My custom config.xml in location magento\app\code\local\XYZ\Catalog\etc

<?xml version="1.0"?>
<config>
  <
frontend>
    <
events>
      <
catalog_product_save_after>
        <
observers>
          <
my_custom_observer>
            <
type>model</type>
            <class>
XYZ_Catalog_Model_Observer</class>
            <
method>post_save</method>
          </
my_custom_observer>
        </
observers>
      </
catalog_product_save_after>
    </
events>
  </
frontend>
</
config>

My Observer class is in location magento\app\code\local\XYZ\Catalog\Model

<?php
class XYZ_Catalog_Model_Observer  extends Mage_Core_Model_Abstract
{
  
public function post_save($observer)
  
{
    $event 
$observer->getEvent();
    
$product $event->getProduct();

    
Mage::log('Observer Called');
    
// ... add my custom code to be spawned during the event
    // ... may update the argument objects, or do any other action.
  
}
}

Have registered my new module in magento\app\etc\modules\XYZ.xml

<?xml version="1.0"?>
<config>
  <
modules>
    <
XYZ_Catalog>
      <
codePool>local</codePool>
      <
active>true</active>
    </
XYZ_Catalog>
  </
modules>
</
config>

I tried refreshing cache, stopping and starting the WAMP server and checked that the custom module is enabled (in admin). But it still doesn’t seem to work. Has someone worked with Events before. Please help!

I basically am required to get the product’s attribute set code and atttributes and store them in different custom tables and columns.

Thanks in advance.

 
Magento Community Magento Community
Magento Community
Magento Community
 
srinigenie
Guru
 
Avatar
Total Posts:  539
Joined:  2008-02-04
 

Finally got this working ..thanks to Moshe!!

Event-Dispatch

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top