Reputation: 1076
I have a magento extension which sends user data to an aPI on newsletter_subscriber_save_before
event. But now I have to send something more to that api and that new var is only available at newsletter_subscriber_save_after
.
Question is how can I stop newsletter_subscriber_save_before
for that module with out removing from extenion's config.xml.
If I keep both it will send data twice to api and if I remove newsletter_subscriber_save_before
from extension it will come again if someone upgrades it.
I don't want disable, as it disable event from everywhere.
Upvotes: 2
Views: 1535
Reputation: 24551
I don't want disable, as it disable event from everywhere.
But disabling the observer is the right way. Exactly for this use case the observer type "disabled" exists.
So if the extension has configured the observer like this:
<events>
<newsletter_subscriber_save_before>
<observers>
<some_unique_code>
<type>singleton</type>
<class>extension/observer</class>
<method>sendSomething</method>
</some_unique_code>
</observers>
</newsletter_subscriber_save_before>
</events>
you can disable it in your own extensions config like this:
<events>
<newsletter_subscriber_save_before>
<observers>
<some_unique_code>
<type>disabled</type>
</some_unique_code>
</observers>
</newsletter_subscriber_save_before>
</events>
Pay attention that you define this in the same area (frontend, adminhtml or global) and use the same observer code ("some_unique_code" in my example) as the original.
What's important is that your extension gets loaded after the original one, you achieve that with a dependency in your XML in app/etc/modules/
:
<depends>
<Other_Extension />
</depends>
Upvotes: 4
Reputation: 36
In config.xml you can use the same event name and thus change the event method to an empty one.
Upvotes: 2