Skip to content

Commit df83632

Browse files
committed
MAGETWO-93061: CMS page of second website with same URLkey as first website, show content of First website instead of second website content.
- Fix static test
1 parent 523968c commit df83632

File tree

1 file changed

+25
-19
lines changed

1 file changed

+25
-19
lines changed

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

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,12 @@ public function switch(StoreInterface $fromStore, StoreInterface $targetStore, s
6363
}
6464

6565
$oldStoreId = $fromStore->getId();
66-
$oldRewrite = $this->urlFinder->findOneByData([
67-
UrlRewrite::REQUEST_PATH => $urlPath,
68-
UrlRewrite::STORE_ID => $oldStoreId,
69-
]);
66+
$oldRewrite = $this->urlFinder->findOneByData(
67+
[
68+
UrlRewrite::REQUEST_PATH => $urlPath,
69+
UrlRewrite::STORE_ID => $oldStoreId,
70+
]
71+
);
7072
if ($oldRewrite) {
7173
$targetUrl = $targetStore->getBaseUrl();
7274
// look for url rewrite match on the target store
@@ -75,13 +77,13 @@ public function switch(StoreInterface $fromStore, StoreInterface $targetStore, s
7577
$targetUrl .= $currentRewrite->getRequestPath();
7678
}
7779
} else {
78-
$existingRewrite = $this->urlFinder->findOneByData([
79-
UrlRewrite::REQUEST_PATH => $urlPath
80-
]);
81-
$currentRewrite = $this->urlFinder->findOneByData([
82-
UrlRewrite::REQUEST_PATH => $urlPath,
83-
UrlRewrite::STORE_ID => $targetStore->getId(),
84-
]);
80+
$existingRewrite = $this->urlFinder->findOneByData([UrlRewrite::REQUEST_PATH => $urlPath]);
81+
$currentRewrite = $this->urlFinder->findOneByData(
82+
[
83+
UrlRewrite::REQUEST_PATH => $urlPath,
84+
UrlRewrite::STORE_ID => $targetStore->getId(),
85+
]
86+
);
8587

8688
if ($existingRewrite && !$currentRewrite) {
8789
/** @var \Magento\Framework\App\Response\Http $response */
@@ -100,15 +102,19 @@ public function switch(StoreInterface $fromStore, StoreInterface $targetStore, s
100102
*/
101103
private function findCurrentRewrite(UrlRewrite $oldRewrite, StoreInterface $targetStore)
102104
{
103-
$currentRewrite = $this->urlFinder->findOneByData([
104-
UrlRewrite::TARGET_PATH => $oldRewrite->getTargetPath(),
105-
UrlRewrite::STORE_ID => $targetStore->getId(),
106-
]);
107-
if (!$currentRewrite) {
108-
$currentRewrite = $this->urlFinder->findOneByData([
109-
UrlRewrite::REQUEST_PATH => $oldRewrite->getTargetPath(),
105+
$currentRewrite = $this->urlFinder->findOneByData(
106+
[
107+
UrlRewrite::TARGET_PATH => $oldRewrite->getTargetPath(),
110108
UrlRewrite::STORE_ID => $targetStore->getId(),
111-
]);
109+
]
110+
);
111+
if (!$currentRewrite) {
112+
$currentRewrite = $this->urlFinder->findOneByData(
113+
[
114+
UrlRewrite::REQUEST_PATH => $oldRewrite->getTargetPath(),
115+
UrlRewrite::STORE_ID => $targetStore->getId(),
116+
]
117+
);
112118
}
113119
return $currentRewrite;
114120
}

0 commit comments

Comments
 (0)