Magento 2 facilitates to setup multiple stores. It is needed when a store owner decides to expand the business or wants to manage multiple stores from a single administration or establish stores for more than one locations. Magento 2 Multi Store setup benefits in many ways, such as:
- Using single payment gateway in all the stores to save cost.
- You can get unified support for all the created stores while using third party extensions and integrations.
- Boilerplate content for the pages like terms and conditions, privacy policy, etc.
- Retain a common customer database to use in all the stores.
- Useful in the responsive frameworks.
Magento 2 Multi Store setup facility allows creating as many stores as you need in the single configuration.
Steps to Setup Magento 2 Multi Store:
- Create a New Website
- Create a New Store
- Navigate to Store > Settings > All Stores.
- On the Stores page, click Create Store.
- Choose the Website of your choice.
- Name the Store.
- Choose the Root Category that needs to be displayed within that store.To add a new root category follow the steps below.
- Go to Product > Categories.
- Click Add Root Category in the left column of the page.
- Enter the Category Name, enable the category and Save the changes.
- Save Store.
- Create a New Store View
- Check for Mode and Access PermissionsNote: Only beginners need to check for this step. It is required to enable the developer mode.
- Give permissions to the below directories.12345chmod -R a+wX varchmod -R a+wX app/etcchmod -R a+wX pub
- The command to change the mode is,Alternative Method:1bin/magento deploy:mode:set developer
- Go to app/etc/ and open env.php
- Change current application mode by MAGE_MODE’ => ‘default’ to MAGE_MODE’ => ‘developer’.
- Give permissions to the below directories.
- Create a New Website
- Create folder from your root directory eg. demo5, and copy the index.php file and .htaccess file from the Magento root directory to the directory created for the new website within the Magento root directory.
- Replace the code of index.php into the following code snippet:123456789101112<?phprequire realpath(__DIR__) . '/../app/bootstrap.php'; // path of root magento bootstrap.php$params = $_SERVER;$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'base'; // change this with the code you chose in step. 4$params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'website'; // store or website$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params);$app = $bootstrap->createApplication('Magento\Framework\App\Http');$bootstrap->run($app);
- In the Admin, navigate to Stores > Settings > Configuration > General > Web.
- From the Store View listed on the top of the page, choose a website, other than the default website.
- In the right panel, expand Base URLs. Unselect Use Default. Consider the following as examples to fill the fields.
- Base URL : Enter the base URL.
- Base Link URL : Enter base link URL.
- Base URL for Static View Files(default value) :Enter URL for static view files.
- Base URL for User Media Files(default value) : Enter URL for media files.Fill the same in the fields under Base URLs (Secure) if needed for ‘https’ access.
- Save Config.
- Navigate to System > Tools > Cache Management and click Flush Magento Cache.
- Now you can view the different stores and the store views in the browser by specifying the corresponding URLs.
Using SSH, create the following symbolic links in the document root of your new domain, and replace the path below with the full path to the document root of your Magento Installation:
1234ln -s /home/example/example.com/html/app/ appln -s /home/example/example.com/html/lib/ libln -s /home/example/example.com/html/pub/ publn -s /home/example/example.com/html/var/ var- If you have successfully configured your secondary domain to work with Magento, your new domain will load in your browser, and you may begin developing your new store.
Follow this stepwise tutorial and you’re all ready to setup Magento 2 multi store!
It being a lengthy tutorial, if you face a problem in implementation at any step, please post your doubts in the Comments section. I’d be happy to help you out.
Rate the tutorial with 5 stars if found helpful 🙂
All the best for your multi stores ?
Get Weekly Updates
Never miss Magento tips, tricks, tutorials, and news.
Thank you for subscribing.
Something went wrong.
4 comments On How to Setup Magento 2 Multi Store
Hi,
I have created demo folder inside magento root directory and copied 2 files as mentioned and updated index file as mentioned.. Still the subdomain is not showing content. Have i missed any step?
Hello Kruthika,
Please check if you have pointed the domain properly to the new folder created.
Also, try to create and access the test.php file. If it is proper, then there is mistake in following the mentioned steps.
Thanks.
Hello Sanjay,
I am aware with this step. But it is not possible in Commerce Cloud. I have tried to implement but in Cloud DevDocs says different with it.
Hello Arpit,
The above solution is tested with only Magento Open Source edition.
Thank you.