Simulate store to set or get store specific values

In earlier Magento versions it was quite difficult to set or read store specific values on entities. In most cases you have to set the store on the whole application instance like that:


Sometimes it was even necessary to add the store  to entities or collections it-selves too.

Now (at least EE 1.14) you can do it this way:

$oEmulator = Mage::getSingleton('core/app_emulation');

$iStoreID = 88; // The store to simulate

$oRollbackState = $oEmulator->startEnvironmentEmulation($iStoreID);

// do something store specific f.e: read or set product / category attributes


This works for Front- and Backend!

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.