0

I have installed Magento 2.0.9

I am attempting to create following store configuration

Website            Store             StoreView   BaseUrl   Storecode
-----------------------------------------------------------------------
Main Website   Main Website Store    Portuguese  domain1.com   dp1
Main Website   Main Website Store    English     domain1.com   de1
Main Website   Fashion Store         Portuguese  domain2.com   dp2
Main Website   Fashion Store         English     domain2.com   de2
-----------------------------------------------------------------------

domain1.com contains all products: Books, jewelry, clothing etc. I have created a Fashion store with just jewelry category products and I am able to view domain2.com successfully.

The problem is when I change the storeview of both the domain1.com or domain2.com from Portuguese to English/English to Portuguese there is no effect. However I am to access the page by the urls directly : domain2.com/de2 and domain2.com/dp2 they work.

Can any tell me or suggest what should I do to get the store switching to work?

0

I recently did a similiar thing to seperate the shops from two languages / countries.

You have to edit your index.php file to make that possible:

switch ($_SERVER['HTTP_HOST']) {
case 'www.domain1.com':
case 'domain1.com':
    $params = $_SERVER;
    $params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = '';
    $params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'store';
    $bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params);
    $app = $bootstrap->createApplication('Magento\Framework\App\Http');
    $bootstrap->run($app);
    break;
case 'www.domain2.com':
case 'domain2.com':
    $params = $_SERVER;
    $params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = '';
    $params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'store';
    $bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params);
    $app = $bootstrap->createApplication('Magento\Framework\App\Http');
    $bootstrap->run($app);
    break;
default:
    Mage::run();
break;}

You need to fill in the specific store_view code depending on your domain on:

$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = '';

As I said, i did that for a multidomain shop with 3 different domains linking to one Magento installation. Never had to use two seperate Domains to link the the same "Website" but an other "storeview". You can learn more about this topic here: Magento 2 with multiple domain names

  • Thanks for the reply Marcel. I am able to access different domains but I am unable to switch between storeviews within each domain though I see the different storeviews as dropdown on the top right corner(English,Portuguese). When I select the storeview it refreshes to default storeview. Any help will be appreciated. – MH PS Nov 28 '17 at 11:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.