Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
<?php
// Get the old store
$oldStore = Mage::app()->getStore(true);
// Set the new store
/* @var $customer Mage_Customer_Model_Customer */
$newStore = Mage::app()->getStore($customer->getStoreId());
Mage::app()->setCurrentStore($newStore);
// Here my code... Am I really on the new store?
// Set the old store
Mage::app()->setCurrentStore($oldStore);
<?php
// Start emulation
/* @var $customer Mage_Customer_Model_Customer */
/* @var $emulator Mage_Core_Model_App_Emulation */
$emulator = Mage::getModel('core/app_emulation');
$initial = $emulator->startEnvironmentEmulation($customer->getStoreId());
// Here my code... Yes! I'm really on the new store!
// Stop emulation
$emulator->stopEnvironmentEmulation($initial);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment