Skip to content

Commit

Permalink
#11211 Fix Store View switcher
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagolima-bm committed Oct 10, 2017
1 parent 9304040 commit ce4fb97
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions app/code/Magento/Store/Model/Store.php
Original file line number Diff line number Diff line change
Expand Up @@ -1166,6 +1166,9 @@ public function getCurrentUrl($fromStore = true)
if (!$this->isUseStoreInUrl()) {
$storeParsedQuery['___store'] = $this->getCode();
}
if ($this->getCode() !== $this->_storeManager->getStore()->getCode()) {
$fromStore = true;
}
if ($fromStore !== false) {
$storeParsedQuery['___from_store'] = $fromStore ===
true ? $this->_storeManager->getStore()->getCode() : $fromStore;
Expand All @@ -1175,9 +1178,14 @@ public function getCurrentUrl($fromStore = true)
. '://'
. $storeParsedUrl['host']
. (isset($storeParsedUrl['port']) ? ':' . $storeParsedUrl['port'] : '')
. $storeParsedUrl['path']
. $requestString
. ($storeParsedQuery ? '?' . http_build_query($storeParsedQuery, '', '&') : '');
. $storeParsedUrl['path'];

//avoid query params duplication
if (!preg_match('/___store=(.*?)&___from_store=(.*?)/', $requestString)) {
$currentUrl .= $requestString;
}

$currentUrl .= ($storeParsedQuery ? '?' . http_build_query($storeParsedQuery, '', '&') : '');

return $currentUrl;
}
Expand Down

0 comments on commit ce4fb97

Please sign in to comment.