Skip to content

Commit 38feef1

Browse files
committed
MAGETWO-69107: [Backport] - [Magento Cloud] Switching stores not working properly - for 2.1
- Fix store switcher
1 parent 8b3a1c1 commit 38feef1

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,18 +1160,29 @@ public function getCurrentUrl($fromStore = true)
11601160
if (!$this->isUseStoreInUrl()) {
11611161
$storeParsedQuery['___store'] = $this->getCode();
11621162
}
1163+
11631164
if ($fromStore !== false) {
11641165
$storeParsedQuery['___from_store'] = $fromStore ===
11651166
true ? $this->_storeManager->getStore()->getCode() : $fromStore;
11661167
}
11671168

1169+
$requestStringParts = explode('?', $requestString, 2);
1170+
$requestStringPath = $requestStringParts[0];
1171+
if (isset($requestStringParts[1])) {
1172+
parse_str($requestStringParts[1], $requestString);
1173+
} else {
1174+
$requestString = [];
1175+
}
1176+
1177+
$currentUrlQueryParams = array_merge($requestString, $storeParsedQuery);
1178+
11681179
$currentUrl = $storeParsedUrl['scheme']
11691180
. '://'
11701181
. $storeParsedUrl['host']
11711182
. (isset($storeParsedUrl['port']) ? ':' . $storeParsedUrl['port'] : '')
11721183
. $storeParsedUrl['path']
1173-
. $requestString
1174-
. ($storeParsedQuery ? '?' . http_build_query($storeParsedQuery, '', '&') : '');
1184+
. $requestStringPath
1185+
. ($currentUrlQueryParams ? '?' . http_build_query($currentUrlQueryParams, '', '&') : '');
11751186

11761187
return $currentUrl;
11771188
}

0 commit comments

Comments
 (0)