54 private $storeSwitcher;
67 ActionContext $context,
74 parent::__construct($context);
79 $this->messageManager = $context->getMessageManager();
91 $targetStoreCode = $this->_request->getParam(
93 $this->storeCookieManager->getStoreCodeFromCookie()
95 $fromStoreCode = $this->_request->getParam(
'___from_store');
97 $requestedUrlToRedirect = $this->
_redirect->getRedirectUrl();
98 $redirectUrl = $requestedUrlToRedirect;
102 $fromStore = $this->storeRepository->get($fromStoreCode);
103 $targetStore = $this->storeRepository->getActiveStoreByCode($targetStoreCode);
105 $error =
__(
'Requested store is inactive');
107 $error =
__(
"The store that was requested wasn't found. Verify the store and try again.");
109 if ($error !==
null) {
110 $this->messageManager->addErrorMessage($error);
112 $redirectUrl = $this->storeSwitcher->switch($fromStore, $targetStore, $requestedUrlToRedirect);
_redirect($path, $arguments=[])
__construct(ActionContext $context, StoreCookieManagerInterface $storeCookieManager, HttpContext $httpContext, StoreRepositoryInterface $storeRepository, StoreManagerInterface $storeManager, StoreSwitcherInterface $storeSwitcher=null)