Last active
November 30, 2016 14:42
-
-
Save mehdichaouch/cd4969747eec9e5a725e65e006788398 to your computer and use it in GitHub Desktop.
Magento - Store emulation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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