Skip to content

Instantly share code, notes, and snippets.

@jacquesbh
Created November 10, 2013 17:57
Show Gist options
  • Save jacquesbh/7401505 to your computer and use it in GitHub Desktop.
Save jacquesbh/7401505 to your computer and use it in GitHub Desktop.
<?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