-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#11211 Fix Store View switcher #11337
Conversation
@@ -1166,6 +1166,9 @@ public function getCurrentUrl($fromStore = true) | |||
if (!$this->isUseStoreInUrl()) { | |||
$storeParsedQuery['___store'] = $this->getCode(); | |||
} | |||
if ($this->getCode() !== $this->_storeManager->getStore()->getCode()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thiagolima-bm Please explain why usage of __from_store
query parameter should be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for tracking, maybe?
|
||
//avoid query params duplication | ||
if (!preg_match('/___store=(.*?)&___from_store=(.*?)/', $requestString)) { | ||
$currentUrl .= $requestString; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$requestCode
also contains path and this data may be lost
STR:
- go to Privacy and Cookie Policy
- switch store view (store view switched, user still on Privacy and Cookie Policy)
- switch store view again (store view switched, user on main page but should be on Privacy and Cookie Policy)
$currentUrl .= $requestString; | ||
} | ||
|
||
$currentUrl .= ($storeParsedQuery ? '?' . http_build_query($storeParsedQuery, '', '&') : ''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the source of the issue is concatenation with ?
while $requestString
may contain query. To fix this I propose:
- Split
$requestString
into path and query:
$requestStringParts = explode('?', $requestString, 2);
$requestStringPath = $requestStringParts[0];
if (isset($requestStringParts[1])) {
parse_string($requestStringParts[1], $requestStringQuery);
} else {
$requestStringQuery = []
}
- Merge original query params and store parsed query
$currentUrlQueryParams = array_merge($requestStringQuery, $storeParsedQuery);
- Safely concatenate all parts of url:
$currentUrl = $storeParsedUrl['scheme']
. '://'
. $storeParsedUrl['host']
. (isset($storeParsedUrl['port']) ? ':' . $storeParsedUrl['port'] : '')
. $storeParsedUrl['path']
. $requestStringPath
. ($currentUrlQueryParams ? '?' . http_build_query($currentUrlQueryParams, '', '&') : '');
@vkublytskyi fixes applied. |
[EngCom] Public Pull Requests - 2.2-develop - MAGETWO-82955: [Backport 2.2-develop] FIX show visual swatches in admin - product attribute #11747 - MAGETWO-82943: Magetwo 70954: Remove the component.clear from the custom options type. This causes the 'elem' array to become out of sync with the recordData #11824 - MAGETWO-82710: Fix issue #10032 - Download back-up .tgz always takes the latest that's created (2.2-develop) #11595 - MAGETWO-81994: Products added to cart with REST API give total prices equal to zero #11458 - MAGETWO-81422: #11211 Fix Store View switcher #11337
Gents, still not able to manage this issue to get it work (( |
Store View switcher not working on front-end and it throws an error #11211 #10908