How to Setup Magento 2 Multi Store

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:

  1. Create a New Website
    1. Login to Magento Backend
    2. Navigate to Store > Settings > All Stores.
    3. On the Stores page, click Create Website.
      1. Name: Enter your website name.
      2. Code: Enter the unique code for the website.
      3. Sort Order: It is an optional field and is set to maximum value ‘0’ by default.
    4. Save Web Site.1_Create-a-Website
  2. Create a New Store
    1. Navigate to Store > Settings > All Stores.
    2. On the Stores page, click Create Store.
      1. Choose the Website of your choice.
      2. Name the Store.
      3. Choose the Root Category that needs to be displayed within that store.To add a new root category follow the steps below.
        1. Go to Product Categories.
        2. Click Add Root Category in the left column of the page.
        3. Enter the Category Name, enable the category and Save the changes.
    3. Save Store.2_Create-New-Store
  3. Create a New Store View
    1. Navigate to Store > Settings > All Stores.
    2. On the Stores page, click Create Store View.
      1. Choose the Store of your choice.
      2. Name the Store View.
      3. Set the status Enabled.
    3. Status is an optional field. It is set to maximum value ‘0’ by default.
    4. Save Store View.3_Create-New-StoreView
  4. Check for Mode and Access PermissionsNote: Only beginners need to check for this step. It is required to enable the developer mode.
    1. Give permissions to the below directories.
       
    2. The command to change the mode is,
      Alternative Method:

      1. Go to app/etc/ and open env.php
      2. Change current application mode by MAGE_MODE’ => ‘default’ to MAGE_MODE’ => ‘developer’.
  5. Create a New Website
    1. 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.
    2. Replace the code of index.php into the following code snippet:
    3. In the Admin, navigate to Stores > Settings > Configuration > General > Web.
    4. From the Store View listed on the top of the page, choose a website, other than the default website.
    5. In the right panel, expand Base URLs. Unselect Use Default. Consider the following as examples to fill the fields.
      1. Base URL : Enter the base URL.
      2. Base Link URL : Enter base link URL.
      3. Base URL for Static View Files(default value) :Enter URL for static view files.
      4. 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.4_Base-URLs
  6. Save Config.
  7. Navigate to System > Tools > Cache Management and click Flush Magento Cache.
  8. Now you can view the different stores and the store views in the browser by specifying the corresponding URLs.
  9. 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:

  10.  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 ?

5
(based on 27 Reviews)
How to Setup Magento 2 Multi Store

Sanjay Jethva

Sanjay is a co-founder at Meetanshi. He is a Certified Magento Developer who loves creating Magento E-commerce solutions. Owing to his contributions in Magento Forums and posting solutions, he is among the top 50 contributors of the Magento community in 2019. When he is not engrossed with anything related to Magento, he loves to play cricket.

11 Comments

  • Rex

    When I change files in one of my store directory css, eventually the rest of the stores also changed.
    Every time I edit one store file, the changes made was also save to other stores.
    How to get rid of this?
    Each store should have unique styles.

  • Amber

    Hello Sanjay, It seems my comment disappeared after leaving one. I got on the step for changing the base URL. I changed the “scope” to my selected store view for the one I wanted to change. I am on localhost using Apache 2.4, My SQL 5.7 and PHP 7.3. I followed the guide until the base URL step. I changed my first store view URL (I am setting up 2 stores under one website to share checkout, but have separate root categories and store fronts), and then I hit save. I got immediately kicked out of admin and now I cannot figure out how to log back into this. I have tried setting up virtual host and changing the db in phpMyAdmin for the site URL but no luck. I have also flushed the cache after changes. This keeps happening so I keep having to do a fresh install of Magento Open Source 2.3.5. I cannot figure out where this is going wrong.

  • Amber

    Hello Sanjay, I am in step 5 in changing the base URL using Magento Open Source 2.3.5. I am trying to setup 2 stores. In changing the base URL, you say to select the website, but would I select “website” or the “store view”? Both of my “store views” will need their own URL. Here is a screenshot: https://prnt.sc/10g6oll

  • Ajay

    Hi Sanjay
    I have a step according to the above step but the subdomain run on the browser shows a Forbidden error 403.

  • Kruthika

    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?

    • Sanjay Jethva

      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.

  • Arpit

    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.

Leave a Reply

Your email address will not be published. Required fields are marked *