In this tutorial setup Magento Multiple Websites with Multiple Stores view in Magento 2. I will show you my experience in our recent project. This website requires setup Multiple websites with multiple store language. We have used Magento 2 for this project. I hope this tutorial will help someone.
Example, we want setup 4 domain websites and multiple store language for each site
- diegos.com include 3 language: English, Spanish, French
- ca.diegos.com include 2 language: English, French
- uk.diegos.com include only one language: English
- eu.diegos.com include 3 languages: English, Spanish, French
>>> READ MORE: Magento Multi Vendor Theme
The steps to Setup Magento Multi Languages for your Store.
- Step 1: Create New Website, Store, Store View
- Step 2: Setup Store URL for each Store
- Step 3: Update file Index.php
Step 1: Create New Website, Store, Store View
+ Create New Website: Click button Create Website to create 4 websites: diegos.com, ca.diegos.com, uk.diegos.com, eu.diegos.com
+ Create New Store: Click button Create Store to create Store for each website. In this case you need to create 4 Store for each 4 website.
+ Create New Store View: Click button Create Store View to create store language for each webiste
- diegos.com website have 3 language with code: en , es, fr
- ca.diegos.com website have 2 language with code: enca, frca
- uk.diegos.com website have include 1 language with code: enuk
- eu.diegos.com website have 3 languages with code: eneu, eseu, freu
Step 2: Setup URL for each Store
Go to: Stores > Settings > Configuration
On the left panel , go to: General > Web
Fill the Base URL for each store
Step 3: Update file Index.php
Open file index.php and change as bellow to bring domain website to correct store view.
See example code bellow”
[php] $bootstrap = MagentoFrameworkAppBootstrap::create(BP, $_SERVER); switch($_SERVER['HTTP_HOST']) { case 'uk.diegos.com': $params = $_SERVER; $params[MagentoStoreModelStoreManager::PARAM_RUN_CODE] = 'base_uk'; $params[MagentoStoreModelStoreManager::PARAM_RUN_TYPE] = 'website'; $bootstrap = MagentoFrameworkAppBootstrap::create(BP, $params); break; case 'ca.diegos.com': $params = $_SERVER; $params[MagentoStoreModelStoreManager::PARAM_RUN_CODE] = 'base_ca'; $params[MagentoStoreModelStoreManager::PARAM_RUN_TYPE] = 'website'; $bootstrap = MagentoFrameworkAppBootstrap::create(BP, $params); break; case 'eu.diegos.com': $params = $_SERVER; $params[MagentoStoreModelStoreManager::PARAM_RUN_CODE] = 'base_eu'; $params[MagentoStoreModelStoreManager::PARAM_RUN_TYPE] = 'website'; $bootstrap = MagentoFrameworkAppBootstrap::create(BP, $params); break; default: $bootstrap = MagentoFrameworkAppBootstrap::create(BP, $_SERVER); } $app = $bootstrap->createApplication('MagentoFrameworkAppHttp'); $bootstrap->run($app); [/php]
Now Your Magento Multiple Website Ready To Go Live!.
if you have any question for me, feel free to leave a comment bellow.
RELATED POST: How to Add RSS Feed to Magento – How to add magento multi language for ecommerce store