storeManager->getStore()->getCode(); return $this->storeCodeMapper->isRealStoreCodeInScope($storeCode) ? $storeCode : $this->resolveDefaultStoreCode(); } catch (\Throwable $exception) { return $this->resolveDefaultStoreCode(); } } private function resolveDefaultStoreCode(): string { $language = $this->request instanceof \Magento\Framework\App\Request\Http ? $this->languageResolver->resolveFromPath($this->request->getPathInfo()) : null; if ($language === null) { return ''; } return $this->storeCodeMapper->getDefaultStoreCodeForLanguage($language) ?: ''; } public function execute() { $country = $this->getRequest()->getParam('country'); $language = $this->getRequest()->getParam('language'); $success = false; if (!empty($country) && !empty($language)) { $market = strtolower($language).'_'.strtoupper($country); $storeCode = $this->resolveStoreCode(); $logger = ObjectManager::getInstance()->get(LoggerInterface::class); $logger->info('$market: '.$market); $this->httpContext->setValue( AddHttpContextObserver::CONTEXT_MARKET, $market, $this->resolveDefaultStoreCode() ); $this->httpContext->setValue( AddHttpContextObserver::CONTEXT_STORE_CODE, $storeCode, $this->resolveDefaultStoreCode() ); $success = true; } return $this->resultJsonFactory->create() ->setData([ 'success'=>$success, 'country'=>$country, 'language'=>$language ]); } }