Closed mariamghalleb closed 4 years ago
Same issue here, switcher only works on homepage
@mariamghalleb, thank you for your report. We've acknowledged the issue and added to our backlog.
I can also reproduce this Issue on 2.2.5 CE and EE.
best regards,
Lars
Too sad that such core functionality does not work since 2.2.1...
Which guy solved this issue? I have a similar issue 2.2.2#16454; the same issue in 2.2.5
seems to be fixed in 2.2.6
@Cristiano81 Are you sure this is fixed in 2.2.6?
I just tried it and it still does not work correctly using different url_key for the same category for example.
yes, I just tried it and it still does not work correctly using different url_key for the same category for example.
If I am looking at it correctly, it tries to lookup a url rewrite by using the old url and it only changes the store. I don't see how this could ever work unless all stores have the same url.
In version 2.2.5, it looks up a url rewrite by using the entity ID instead
Also it is redirecting twice for some reason, first to stores/store/redirect
then to stores/store/switch
, then to the actual url.
I'm having this same issue in v2.2.6, is there any temporary workarounds?
Facing same issue in v2.2.6. Common guys - anybody with temporary fix? It's a major issue for an ecommerce not being able to switch store view on a product page...
I can’t upgrade a Magento v2.2.2 site because it is a must-have feature switching languages for the product page. I’ve tried some modules to regenerate product and category urls hoping i could fix it but without success :-(
My quickfix for a client now. Still have to do extensive testing.
\Magento\UrlRewrite\Model\StoreSwitcher\RewriteUrl::switch
if ($oldRewrite) {
$currentRewrites = $this->urlFinder->findAllByData([
UrlRewrite::TARGET_PATH => $oldRewrite->getTargetPath(),
UrlRewrite::STORE_ID => $targetStore->getId(),
]);
if (null === $currentRewrites || empty($currentRewrites)) {
/** @var \Magento\Framework\App\Response\Http $response */
$targetUrl = $targetStore->getBaseUrl();
} else {
foreach($currentRewrites as $rewrite) {
$targetUrl = $targetStore->getBaseUrl() . $rewrite->getRequestPath();
break;
}
}
}
My quickfix
It works for me but not for static pages. Thanks, I’ll make some other tests then I’ll apply this quick fix as override in app/code
My quickfix
It works for me but not for static pages. Thanks, I’ll make some other tests then I’ll apply this quick fix as override in app/code
@teoteo
Yes this is only for routes that uses the url rewrites system / module. 'Static' urls and amasty modules are next on my list.
Any news on this issue? Facing the same issue on 2.2.7.
@waldok, there are currently 2 PR's open trying to fix this:
I can't find \Magento\UrlRewrite\Model\StoreSwitcher\RewriteUrl file in 2.2.5 CE ??
@raulsinapsis : it was added in 2.2.6 by https://github.com/magento/magento2/commit/32bca2b3d3cc54201477dc3b83e624808c30df8a#diff-72c711a978f42a0896e4615e7910c87e Not sure if this is helpful.
And I know, this issue is very complex and has been attempted to be solved in many Magento versions in all kinds of different ways. Not sure if #19798 will solve all problems, but it looks pretty promissing.
Thanks @hostep We've solved by upgrading 2.2.5 to 2.2.6 (then \Magento\UrlRewrite\Model\StoreSwitcher\RewriteUrl does exist) and then applying this PR https://github.com/magento/magento2/pull/20093
My quickfix for a client now. Still have to do extensive testing.
\Magento\UrlRewrite\Model\StoreSwitcher\RewriteUrl::switch
if ($oldRewrite) { $currentRewrites = $this->urlFinder->findAllByData([ UrlRewrite::TARGET_PATH => $oldRewrite->getTargetPath(), UrlRewrite::STORE_ID => $targetStore->getId(), ]); if (null === $currentRewrites || empty($currentRewrites)) { /** @var \Magento\Framework\App\Response\Http $response */ $targetUrl = $targetStore->getBaseUrl(); } else { foreach($currentRewrites as $rewrite) { $targetUrl = $targetStore->getBaseUrl() . $rewrite->getRequestPath(); break; } } }
It works!!! Thank you!
the best fix to this issue just replace _fromstore to store in vendor/magento/module-catalog/Controller/Product/View.php and vendor/magento/module-catalog/Controller/Category/View.php
My quickfix for a client now. Still have to do extensive testing.
\Magento\UrlRewrite\Model\StoreSwitcher\RewriteUrl::switch
if ($oldRewrite) { $currentRewrites = $this->urlFinder->findAllByData([ UrlRewrite::TARGET_PATH => $oldRewrite->getTargetPath(), UrlRewrite::STORE_ID => $targetStore->getId(), ]); if (null === $currentRewrites || empty($currentRewrites)) { /** @var \Magento\Framework\App\Response\Http $response */ $targetUrl = $targetStore->getBaseUrl(); } else { foreach($currentRewrites as $rewrite) { $targetUrl = $targetStore->getBaseUrl() . $rewrite->getRequestPath(); break; } } }
Yes this Above Code only works for routes that uses the url rewrites system / module. but not for cms and static url So if you would like to resolve for static cms url then make below change Or Replace Below code in this file (\Magento\UrlRewrite\Model\StoreSwitcher\RewriteUrl::switch):
if ($oldRewrite) { $currentRewrites = $this->urlFinder->findAllByData([ UrlRewrite::TARGET_PATH => $oldRewrite->getTargetPath(), UrlRewrite::STORE_ID => $targetStore->getId(), ]); if (null === $currentRewrites || empty($currentRewrites)) { /** @var \Magento\Framework\App\Response\Http $response */ $targetUrl = $redirectUrl } else { foreach($currentRewrites as $rewrite) { $targetUrl = $targetStore->getBaseUrl() . $rewrite->getRequestPath(); break; } } }
Please check this Solution & Test All the Url in your site and let me know its Helpful to You.
Hi @mariamghalleb.
Thank you for your report and collaboration!
The related internal Jira ticket MAGETWO-93481
was closed as non-reproducible
in 2.2.x
.
It means that Magento team either unable to reproduce this issue using provided Steps to Reproduce from the Description section on clean or the issue has been already fixed in the scope of other tasks.
But if you still run into this problem please update or provide additional information/steps/preconditions in the Description section and reopen this issue.
This was probably fixed by https://github.com/magento/magento2/pull/21140, which should be included in Magento 2.2.9 next week. And it looks like it was already fixed in 2.3.1 by https://github.com/magento/magento2/pull/19798
So we can probably close this issue?
Thank you @hostep
Based on your https://github.com/magento/magento2/issues/14674#issuecomment-504473190 and absence of concerns during all this time, close this issue
Hi @mariamghalleb.
Thank you for your report and collaboration!
The related internal Jira ticket MC-24558
was closed as Fixed
.
The fix will be available with the upcoming 2.4.3
release.
@magento-engcom-team what is the status of this ticket, was this released? could you provide the related pull request
@tuyennn: does my comment above help?
These automated ticket updates by that bot are often incorrect, or maybe @sdzhepa can provide more info?
@hostep It's not, I'm able to replicate the issue on M 2.4.0-p1 for now.
@tuyennn: could you open a new issue with steps of how to reproduce the problem? The storeswitcher feature has been broken and fixed and broken again, many times in many different magento versions. So it could be a slightly different bug the the one in this thread.
@hostep Realized the hardcode 5s caused the problem https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Store/Model/StoreSwitcher/HashGenerator.php#L109
Ah right, you are talking about https://github.com/magento/magento2/issues/33042, okay, good to know!
Preconditions
Steps to reproduce
Expected result
Actual result