From c8abb139f8006826989fe4231dabc21fd4a02fd0 Mon Sep 17 00:00:00 2001 From: Magento EngCom Team Date: Tue, 23 Jan 2018 10:56:37 -0600 Subject: [PATCH] :arrow_double_up: Forwardport of magento/magento2#11337 to 2.3-develop branch Applied pull request patch https://github.com/magento/magento2/pull/11337.patch (created by @thiagolima-bm) based on commit(s): 1. ce4fb9740ec8a362f77110ff9755f871d5187fdd 2. beccd7dd47b6d8421cb50863acb476d9b9bcec4b 3. 84729b581638e00459fcca63bb6d7a1c77f252b9 Fixed GitHub Issues in 2.3-develop branch: - magento/magento2#10908: [2.2.0-rc3.0] Language switcher is broken when using multiple times (reported by @hostep) - magento/magento2#11211: Store View switcher not working on front-end and it throws an error (reported by @latypatil) --- app/code/Magento/Store/Model/Store.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Store/Model/Store.php b/app/code/Magento/Store/Model/Store.php index 3dff61b9e7a57..f86788a9a5bcf 100644 --- a/app/code/Magento/Store/Model/Store.php +++ b/app/code/Magento/Store/Model/Store.php @@ -1182,18 +1182,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; }