Please note that it's not another "how to setup multistore". I've read other questions and it seems that my problem is not described.
Following are not answering my question:
- set default page to Particular store view
- How to create Multiple Store with different domain in Magento
- Multiple Domains, multiple Store View and redirect
- How to set up second store in multi-domain configuration?
- Optimise URL when changing Store and language switcher to maintain SEO standards
I think this question describes the same issue but the answer is kind of workaround Separate store view which reverts back to the default store view
I want to have different store views with different domains. I've created all store views like below:
START OF STANDARD SETUP, NOTHING FANCY, YOU CAN SKIP READING THIS
base
---- store
-------- polish (default)
-------- german
-------- ...
And I've set web_[un]secure_base_url
for each and put them in index.php
.
switch ($_SERVER['HTTP_HOST']) {
case 'polishstore.pl':
$mageRunCode = 'polish';
$mageRunType = 'store';
break;
case 'germanstore.de':
$mageRunCode = 'german';
$mageRunType = 'store';
break;
// ...
default:
$mageRunCode = 'polish';
$mageRunType = 'store';
}
Note that I've also set in configuration:
- Add Store Code to Urls: No
- Auto-redirect to Base URL: No
END OF STANDARD SETUP, NOTHING FANCY
Description of the problem
It works pretty good, but I faced some issues:
- When going to http://polishstore.pl/?___store=german it sets cookie
store=german
and loads german store. From now http://polishstore.pl/ loads incorrectly german store. When going to http://germanstore.de/?___store=polish it doesn't set cookie
store
because this store view is default. But it loads polish store. Consecutive visits without___store
loads correctly german store.// app/code/core/Mage/Core/Model/App.php:562 if ($store->getWebsite()->getDefaultStore()->getId() == $store->getId()) { $this->getCookie()->delete(Mage_Core_Model_Store::COOKIE_NAME); }
- In such situation it is not possible to access polish store anymore, because of cookie. Helps only deleting that cookie or accessing http://polishstore.pl/?___store=polish.
Alternative scenarios that I've tried
Please note that setting Auto-redirect to Base URL to Yes doesn't help, because then it works as described below:
- http://polishstore.pl/?___store=german -> http://germanstore.de cookie
store=german
- http://germanstore.de/?___store=polish -> http://polishstore.pl no cookie -> http://germanstore.de (because of cookie from step 1)
I would like to make it that domain name tells which store view to load, no matter if cookie is set. It may be that the parameter ___store
overrides it but it's not required.
Possible soultions
- Delete cookie
store
or don't set it at all. Deleting cookie in index.php is not working correctly, it works on the second pageload. - Ignore
___store
parameter. Use only domain names to determine which store to load.
In both situations it is needed to modify Mage_Core_Model_App
(copy it to local). Maybe you have better idea. Please comment or post your answer.
store
cookie?