1

I need to create an observer for the event of store switching. Basically I need to do some stuff when the visitor switches storeviews/stores. Where can I find that event?

I cant identify it in this Cheatsheet

1 Answer 1

2

You can use the general event controller_action_predispatch.
This is dispatched for every page called.
In your observer you can check if there is a parameter called ___store sent through GET.
If it is, then the store is switched.
You can get that value like this:

Mage::app()->getRequest()->getParam('___store');

Of course you may get false positives if someone simply adds that parameter in GET manually, but I don't know any other method to check this.
There is no special event dispatched when the store is changed / initialized because this happens very early in the request. It happens in Mage_Core_Model_App::_checkGetStore that is called in the init method in the same class.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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