/** * Process path info * * @param string $pathInfo * @return string * @throws NoSuchEntityException */ public function process($pathInfo) { $pathParts = $this->stripPathBeforeStorecode($pathInfo); $storeCode = $pathParts[0]; $stores = $this->storeManager->getStores(false, true); if (isset($stores[$storeCode])) { $this->storeManager->setCurrentStore($storeCode); $path = '/' . (isset($pathParts[1]) ? $pathParts[1] : ''); } else { $this->storeManager->setCurrentStore(\Magento\Store\Model\Store::DEFAULT_CODE); $path = '/' . implode('/', $pathParts); } return $path; }