Skip to content

Commit ce4fb97

Browse files
committed
#11211 Fix Store View switcher
1 parent 9304040 commit ce4fb97

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

app/code/Magento/Store/Model/Store.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,6 +1166,9 @@ public function getCurrentUrl($fromStore = true)
11661166
if (!$this->isUseStoreInUrl()) {
11671167
$storeParsedQuery['___store'] = $this->getCode();
11681168
}
1169+
if ($this->getCode() !== $this->_storeManager->getStore()->getCode()) {
1170+
$fromStore = true;
1171+
}
11691172
if ($fromStore !== false) {
11701173
$storeParsedQuery['___from_store'] = $fromStore ===
11711174
true ? $this->_storeManager->getStore()->getCode() : $fromStore;
@@ -1175,9 +1178,14 @@ public function getCurrentUrl($fromStore = true)
11751178
. '://'
11761179
. $storeParsedUrl['host']
11771180
. (isset($storeParsedUrl['port']) ? ':' . $storeParsedUrl['port'] : '')
1178-
. $storeParsedUrl['path']
1179-
. $requestString
1180-
. ($storeParsedQuery ? '?' . http_build_query($storeParsedQuery, '', '&') : '');
1181+
. $storeParsedUrl['path'];
1182+
1183+
//avoid query params duplication
1184+
if (!preg_match('/___store=(.*?)&___from_store=(.*?)/', $requestString)) {
1185+
$currentUrl .= $requestString;
1186+
}
1187+
1188+
$currentUrl .= ($storeParsedQuery ? '?' . http_build_query($storeParsedQuery, '', '&') : '');
11811189

11821190
return $currentUrl;
11831191
}

0 commit comments

Comments
 (0)