encoder = $encoder; $this->storeManager = $storeManager; $this->urlBuilder = $urlBuilder; } /** * Returns target store redirect url. * * @param Store $store * @return string * @throws \Magento\Framework\Exception\NoSuchEntityException */ public function getTargetStoreRedirectUrl(Store $store): string { return $this->urlBuilder->getUrl( 'stores/store/redirect', [ '___store' => $store->getCode(), '___from_store' => $this->storeManager->getStore()->getCode(), ActionInterface::PARAM_NAME_URL_ENCODED => $this->encoder->encode( $store->getCurrentUrl(false) ), ] ); } }