When I need to rewrite a function in an observer located in the Enterprise section, how will that rewrite bit look like on 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 follow: class Custom_GiftCard_Model_Observer extends Enterprise_GiftCard_Model_Observer { ..... }
I don't have an enterprise development environment setup at the moment, so this is untested, 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 about and discover the class alias for the gift card observer
<class>enterprise_giftcard/observer</class>
So, with a class alias of enterprise_giftcard/observer
you have a model group name of enterprise_giftcard
, and a model class name of observer
.
In your module's configuration file, first you'll create an area for model configuration
<global>
<models>
</models>
</global>
Then, you'll add the group name of the class you want to rewrite, enterprise_giftcard
<global>
<models>
<enterprise_giftcard>
</enterprise_giftcard>
</models>
</global>
Then, you'll add a node saying you want to rewrite the a single class in this group
<global>
<models>
<enterprise_giftcard>
<rewrite>
</rewrite>
</enterprise_giftcard>
</models>
</global>
The, you'll add a node indicating WHICH class in the group you wish to rewrite, using the name portion of the class alias (observer
)
<global>
<models>
<enterprise_giftcard>
<rewrite>
<observer></observer>
</rewrite>
</enterprise_giftcard>
</models>
</global>
And finally, within this node, you'll add a text node that's 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));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With