Does anyone know if it's possible to unregister an event observer programatically? I have an observer on newsletter_subscribe_save_after
that updates a custom attribute in the customer model but when the customer record is saved it triggers off the customer_save_after
event defined in Mage_All.xml
which then re-saves the newsletter subscription status resulting in an infinite loop that then triggers the PHP recursion error due to nesting 100 times.
Ideally I'd like to unregister the customer_save_after
event only when my observer fires.
Best Answer
You can try to mark your event as
dispatched
and on the second attempt of running it just do nothing if it's already dispatched. For example let's say your method is calledupdateCustomer()
.The registry key name is not important, just make sure you use the same one in both cases.