I have two observers, one for customer_register_success, and one for customer_login which work very well. The issue I'm having is when a customer registers, magento redirects to the login request, and subsequently fires the observer for that. Both are designed to do the same task in a slightly different way, where requests are sent to an external service via api calls, and as you know, api calls can be used up if not used carefully, so avoiding redundancy is critical. Is there a way to set some kind of persistence to avoid the second observer from being fired?


As I was writing this, I thought about the possibility of setting a cookie value that can be checked on the second request.


Will set the custom cookie value, then in the 2nd observer I added

if (Mage::getModel('core/cookie')->get('key') == 'value') 
   return $this;

Or if you want to get rid of the cookie value, use Mage::getModel('core/cookie')->delete('key'); right above return $this;

Mage_Core_Model_Cookie source code

Of course any other suggestions you can think of are definitely welcome.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.