/** * @param GetResponseEvent $event */ public function onKernelRequestSetStore(GetResponseEvent $event) { if (HttpKernelInterface::MASTER_REQUEST === $event->getRequestType() && $this->app) { $store = $this->storeResolver->resolve($event->getRequest()); if (false !== $store) { // keep default store in case manual override fails $defaultStore = $this->app->getStore()->getCode(); $this->app->setCurrentStore($store); try { // try to load the store $this->app->getStore(); } catch (\Mage_Core_Model_Store_Exception $e) { $this->app->setCurrentStore($defaultStore); } } } }
/** * Stop enviromment emulation * * Function restores initial store environment * * @param Varien_Object $initialEnvironmentInfo information about environment of the initial store * * @return Mage_Core_Model_App_Emulation */ public function stopEnvironmentEmulation(Varien_Object $initialEnvironmentInfo) { $this->_restoreInitialInlineTranslation($initialEnvironmentInfo->getInitialTranslateInline()); $initialDesign = $initialEnvironmentInfo->getInitialDesign(); $this->_restoreInitialDesign($initialDesign); // Current store needs to be changed right before locale change and after design change $this->_app->setCurrentStore($initialDesign['store']); $this->_restoreInitialLocale($initialEnvironmentInfo->getInitialLocaleCode(), $initialDesign['area']); return $this; }
public function testSetCurrentStore() { $store = new Mage_Core_Model_Store(); $this->_model->setCurrentStore($store); $this->assertSame($store, $this->_model->getStore()); }