cancel
Showing results for 
Search instead for 
Did you mean: 

Multi Store setup problem

SOLVED

Multi Store setup problem

Hi

I'm tearing my hair our with a multi store setup, I wonder if anyone here can think what I've missed.  I've got three domains pointing to it: webbshop3.mydomain.se, shop2.mydomain.eu and shop.mydomain.lt, and added three websites webbshop3 (default, with 1 view: sv/Swedish), shop2_eu (with 1 view: en_uk/English) and shop_lt (with 3 views: lt/Lithuanian, lv/Latvian and en_lt/English). In stores > configuration > web I have set the base URL and secure base URL for each website to match the domain it should have.

 

If I go to webbshop3.mydomain.se it works as expected.

If I go domains to shop2.mydomain.eu or shop.mydomain.lt, it redirects to webbshop3.mydomain.se. 

But if I type shop.mydomain.lt/lt/ then it displays that view correctly. 

 

My index.php is as follows and to debug I have even tried adding some echo statements to test that the domains are recognised correctly -

 

require __DIR__ . '/app/bootstrap.php';
$params = $_SERVER;
switch($_SERVER['HTTP_HOST']) {
case 'webbshop3.mydomain.se':
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'webbshop3';
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'website';
break;

case 'shop2.mydomain.eu':
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'shop2_eu';
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'website';
break; 

case 'shop.mydomain.lt':
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'shop_lt';
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'website';
break;
}

I've also tried add in .htaccess

SetEnvIf Host shop.mydomain.lt MAGE_RUN_CODE=shop_lt
SetEnvIf Host shop.mydomain.lt MAGE_RUN_TYPE=website

SetEnvIf Host webbshop3.mydomain.se MAGE_RUN_CODE=webbshop3
SetEnvIf Host webbshop3.mydomain.se MAGE_RUN_TYPE=website

SetEnvIf Host shop2.mydomain.eu MAGE_RUN_CODE=shop2_eu
SetEnvIf Host shop2.mydomain.eu MAGE_RUN_TYPE=website

Any ideas about what I've missed would be greatly appreciated!

 

Thanks, Mark

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Multi Store setup problem

Finally found the problem!!

 

After I installed the new version (from Templatemonster) based on Magento 2.2.2, it was still doing the same.  But as it was back to the default installation with Templatemonster's Magnetique theme, which includes a few different sample stores (bike store, spare parts store, underwear, furniture) - there is also a template switcher module to preview/switch between these different options and the thought occurred to me whether that could be interfering with the multistore setup.

 

I disabled it by running the following set of commands over SSH:
php bin/magento module:disable TemplateMonster_LayoutSwitcher -c
php bin/magento setup:upgrade
php bin/magento cache:flush

..and hey presto! :-)

View solution in original post

10 REPLIES 10

Re: Multi Store setup problem

Hi @imark73,

 

Without changing the index.php and using the .htaccess as you shared should work (of course, the websites codes should be right too).

Which .htaccess are you changing?

Re: Multi Store setup problem

Thanks for the reply.

I edited the .htaccess file in the /public_html folder, here is a copy - https://we.tl/ekO5aAzCw5. After reading your question, checked even the .htaccess in the folder above that but it only contains -

 

AddHandler application/x-httpd-php70 .php .php5 .php4 .php3

I checked the codes a number of times, but here they are in case I've missed something -

 

Website name

Code

Default store

View(s)

shop.mydomain.eu

shop_eu

shop_mydomain_eu

English_eu (default) – code: en_uk

shop.mydomain.lt

shop_lt

shop_mydomain_lt

Lithuanian (default) – code: lt

Latvian – code: lv

English – code: en_lt

webbshop3.mydomain.se

webbshop3

mydomain_se

Swedish (default)

 

The only other thing I can think of is that during the development I added the en_lt view to shop_lt.. Originally I only had an English view in shop_eu which simply had the code "en".  In the change if I remember correctly I changed that to en_uk as I found that I couldn't have two views with the code "en" even if they were in separate shops.. Can I have broken something in that change?

 

Edit: Doh! After writing that I just noticed the first code was shop2_eu in index.php but should be shop_eu. Corrected in index.php & .htaccess then flushed the cache and and reindexed.. but still getting the same result :-(

Re: Multi Store setup problem

Hi @imark73,

 

Can you share a public URL of the store?

Re: Multi Store setup problem

Will send a PM, thanks

Re: Multi Store setup problem

Thanks to Damian for pointing out via PM that the domain should point the root directory of the store, on the webserver, to the /pub directory of Magento. Then, edit the .htaccess inside that directory.

 

I also went through my host siteground's recommended configuration 

https://www.siteground.com/tutorials/magento/multistore/ 

..and made some changes to do so. But still get the same result - a couple of siteground's support people have double checked my config as well and say it should work. Very frustrating as I know it was working correctly earlier in the project.

 

Anyway, it's still only a development site and as I've received a fresh version of the template's files including Magento 2.2 (current site is on 2.1.2), think I'm just going to backup and start again with a fresh install.

Re: Multi Store setup problem

Hi @imark73,

 

Thanks for sharing that information.

It will be nice if you can share your experience after starting again to confirm if the problem was on Magento.

Re: Multi Store setup problem

Finally found the problem!!

 

After I installed the new version (from Templatemonster) based on Magento 2.2.2, it was still doing the same.  But as it was back to the default installation with Templatemonster's Magnetique theme, which includes a few different sample stores (bike store, spare parts store, underwear, furniture) - there is also a template switcher module to preview/switch between these different options and the thought occurred to me whether that could be interfering with the multistore setup.

 

I disabled it by running the following set of commands over SSH:
php bin/magento module:disable TemplateMonster_LayoutSwitcher -c
php bin/magento setup:upgrade
php bin/magento cache:flush

..and hey presto! :-)

Re: Multi Store setup problem

I ran into the same problem with multistore but when i disable the module my layouts no longer load. How to fix that issue? Also on my second store the custom CSS does not load from the magetique template.

 

Any ideas? I think its related.

Re: Multi Store setup problem

@FuriomW - my recommendation is to ask templatemonster's support. They've been very helpful with those sorts of issues when I've had to ask.