Skip to content

Instantly share code, notes, and snippets.

@mehdichaouch
Last active November 30, 2016 14:42
Show Gist options
  • Save mehdichaouch/cd4969747eec9e5a725e65e006788398 to your computer and use it in GitHub Desktop.
Save mehdichaouch/cd4969747eec9e5a725e65e006788398 to your computer and use it in GitHub Desktop.
Magento - Store emulation
<?php
// http://inchoo.net/magento/emulate-store-in-magento/
$appEmulation = Mage::getSingleton('core/app_emulation');
//Start environment emulation of the specified store
$initialEnvironmentInfo = $appEmulation->startEnvironmentEmulation($storeId);
/*
* Any code thrown here will be executed as we are currently running that store
* with applied locale, design and similar
*/
//Stop environment emulation and restore original store
$appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo);
// old version
// Frontend store emulation
$storeId = $customer->getStore()->getId();
$currentStore = Mage::app()->getStore();
if ($currentStore->getId() != $storeId) {
Mage::app()->getLocale()->emulate($storeId);
Mage::app()->setCurrentStore(Mage::app()->getStore($storeId));
}
/** send email... **/
// End of emulation
if ($currentStore->getId() != $storeId) {
Mage::app()->getLocale()->revert();
Mage::app()->setCurrentStore($currentStore);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment