I'm currently running Magento 2.2.1 and want to create links to a specific store view.
Each store view is translated to a certain language, and I'd like that links placed on blogs written in that language go directly to the respective store view.
I've tried adding the __store=pt query parameter but in Magento 2 this doesn't seem to work. Apparently the store switcher uses a POST call, which I can't do if I'm linking from another site.
Is there something else I can do?
Best Answer
I finally worked this out. It certainly is more complex than it should be but it works.
The problem is that passing the "__store" query param isn't enough for Magento to send the store cookie back. So I do it myself via rewrites.
Instead of using links of the form
http://example.com/some/magento/path/?__store=pt
I usehttp://example.com/pt/some/magento/path/
.Then I have an Apache Rewrite rule to redirect to the correct URL (without the pt in the path):
http://example.com/some/magento/path/
and send the cookie back.Here's what that rewrite looks like: