Skip to content

Commit 3d882cf

Browse files
author
Janak
committed
Fixed store switcher not work multistore setup with different product urls issue
1 parent b36dc04 commit 3d882cf

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

app/code/Magento/UrlRewrite/Model/StoreSwitcher/RewriteUrl.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,19 @@ public function switch(StoreInterface $fromStore, StoreInterface $targetStore, s
6767
]);
6868
if ($oldRewrite) {
6969
// look for url rewrite match on the target store
70-
$currentRewrite = $this->urlFinder->findOneByData([
71-
UrlRewrite::REQUEST_PATH => $urlPath,
70+
$currentRewrites = $this->urlFinder->findAllByData([
71+
UrlRewrite::TARGET_PATH => $oldRewrite->getTargetPath(),
7272
UrlRewrite::STORE_ID => $targetStore->getId(),
7373
]);
74-
if (null === $currentRewrite) {
74+
75+
if (null === $currentRewrites || empty($currentRewrites)) {
7576
/** @var \Magento\Framework\App\Response\Http $response */
7677
$targetUrl = $targetStore->getBaseUrl();
78+
} else {
79+
foreach($currentRewrites as $rewrite) {
80+
$targetUrl = $targetStore->getBaseUrl() . $rewrite->getRequestPath();
81+
break;
82+
}
7783
}
7884
}
7985

0 commit comments

Comments
 (0)