Skip to content

Commit bd1e538

Browse files
author
Janak
committed
Fixed store switcher not work multistore setup with different product urls issue
1 parent 199eff2 commit bd1e538

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
@@ -66,13 +66,19 @@ public function switch(StoreInterface $fromStore, StoreInterface $targetStore, s
6666
]);
6767
if ($oldRewrite) {
6868
// look for url rewrite match on the target store
69-
$currentRewrite = $this->urlFinder->findOneByData([
70-
UrlRewrite::REQUEST_PATH => $urlPath,
69+
$currentRewrites = $this->urlFinder->findAllByData([
70+
UrlRewrite::TARGET_PATH => $oldRewrite->getTargetPath(),
7171
UrlRewrite::STORE_ID => $targetStore->getId(),
7272
]);
73-
if (null === $currentRewrite) {
73+
74+
if (null === $currentRewrites || empty($currentRewrites)) {
7475
/** @var \Magento\Framework\App\Response\Http $response */
7576
$targetUrl = $targetStore->getBaseUrl();
77+
} else {
78+
foreach($currentRewrites as $rewrite) {
79+
$targetUrl = $targetStore->getBaseUrl() . $rewrite->getRequestPath();
80+
break;
81+
}
7682
}
7783
}
7884

0 commit comments

Comments
 (0)