Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Set Current Store View
 
wise_stam
Jr. Member
 
Total Posts:  4
Joined:  2013-01-02
 

Hi all,

Ever since we added an extra Store View (called Wholesale) to our Megento store, my custom Observer code that used to change a product custom attribute have stopped working properly.

Before adding this new Store View, there is only “All Store View” and “Default Store View”, and everytime my Observer is triggered it updates a custom attribute on a product in *assumed to be* “All Store View”, and “Default Store View” will *assumed to* inherited these updated default values.

After adding this new Store View, sometimes my code updates products in “All Store View” and sometimes “Default Store View”, and the attribute values are no longer the same between “All Store View” and “Default Store View” (might be “8” in All Store View and “10” in Default Store View).

I’ve tried to use:

$websites Mage::app()->getWebsites();
$defaultStore $websites[1]->getDefaultStore();
Mage::app()->setCurrentStore($defaultStore);

To set the current store but it doesn’t work..

Is there a methoed that could do similar to a fictional setCurrentStoreView("Default_Store_View") ? So I can guarantee that I’m consistently changing the value of custom attribute on the correct Store View?

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top