Overwriting Magento Gift Card Observer Functions

When I need to rewrite the function in the observer located in the "Enterprise" section, this overwrite bit will look like config.xml.

is it something like this?

<global> <models> <enterprise> <rewrite> <giftcard>Custom_GiftCard_Model_Observer</giftcard> </rewrite> </enterprise> </models> </global> 

My class is declared as follows: the Custom_GiftCard_Model_Observer class extends Enterprise_GiftCard_Model_Observer {.....}

+8
magento
source share
1 answer

I do not have a development environment setting for enterprises at the moment, so this has not been verified, but it should work as described.

If you look at the gift card configuration in

 app/code/core/Enterprise/GiftCard/etc/config.xml 

You can grep and find out the class alias for the gift card observer.

 <class>enterprise_giftcard/observer</class> 

So, with the class alias enterprise_giftcard/observer , you have the model group name enterprise_giftcard and the model class name observer .

In your module configuration file, first create an area for model configuration

 <global> <models> </models> </global> 

Then you add the group name for the class you want to rewrite, enterprise_giftcard

 <global> <models> <enterprise_giftcard> </enterprise_giftcard> </models> </global> 

Then you will add a node message stating that you want to rewrite one class in this group

 <global> <models> <enterprise_giftcard> <rewrite> </rewrite> </enterprise_giftcard> </models> </global> 

You will add a node indicating the WHICH class in the group that you want to rewrite using the part of the class alias name ( observer )

 <global> <models> <enterprise_giftcard> <rewrite> <observer></observer> </rewrite> </enterprise_giftcard> </models> </global> 

And finally, in this node you add the text node, which is the name of your new class.

 <global> <models> <enterprise_giftcard> <rewrite> <observer>Custom_GiftCard_Model_Observer</observer> </rewrite> </enterprise_giftcard> </models> </global> 

You can test your rewrite by instantiating the observer directly and checking its class name

 $model = Mage::getModel('enterprise_giftcard/observer'); var_dump(get_class($model)); 
+17
source share

All Articles