0

I need to create separate website for handheld devices and desktop. For that I created a module to make an observer for the event of controller_action_predispatch. My config.xml observer snippet is as follows.

<global>
  <events>
    <controller_action_predispatch>
       <observers>
         <Company_Module_Model_Observer>
            <type>singleton</type>
            <class>Company_Module_Model_Observer</class>
            <method>switchStore</method>
         </Company_Module_Model_Observer>
       </observers>
     </controller_action_predispatch>
   </events>
 </global>

In Observer.php I've written script to check device type and based on result I set the store. Code snippet is as follows

if($handheldDevice) {
Mage::app()->setCurrentStore('mobile_view'); //It's my store view code
}  

It's switching store fine. I can set different home page for each store and categories too. All cms pages, cart page also seem good. But when I click a category, I'm getting oops error page. Why is it so? (Category is active in admin).

Can anyone help here?

1

Try going to the category url with the normal Magento way to change storeviews: www.url.com/?___store=storecode.

If that also fails, it is certainly a configuration issue and not something related to yourmodule.

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.