diff --git a/app/code/Magento/Store/Model/Store.php b/app/code/Magento/Store/Model/Store.php index 1d100da274465..c7d226eec8cf3 100644 --- a/app/code/Magento/Store/Model/Store.php +++ b/app/code/Magento/Store/Model/Store.php @@ -1166,18 +1166,29 @@ public function getCurrentUrl($fromStore = true) if (!$this->isUseStoreInUrl()) { $storeParsedQuery['___store'] = $this->getCode(); } + if ($fromStore !== false) { $storeParsedQuery['___from_store'] = $fromStore === true ? $this->_storeManager->getStore()->getCode() : $fromStore; } + $requestStringParts = explode('?', $requestString, 2); + $requestStringPath = $requestStringParts[0]; + if (isset($requestStringParts[1])) { + parse_str($requestStringParts[1], $requestString); + } else { + $requestString = []; + } + + $currentUrlQueryParams = array_merge($requestString, $storeParsedQuery); + $currentUrl = $storeParsedUrl['scheme'] . '://' . $storeParsedUrl['host'] . (isset($storeParsedUrl['port']) ? ':' . $storeParsedUrl['port'] : '') . $storeParsedUrl['path'] - . $requestString - . ($storeParsedQuery ? '?' . http_build_query($storeParsedQuery, '', '&') : ''); + . $requestStringPath + . ($currentUrlQueryParams ? '?' . http_build_query($currentUrlQueryParams, '', '&') : ''); return $currentUrl; }