Configuring a Multi Store Setup in Magento 2 Tutorial

Imagine you have a multi-brand business that has many stores around the city, country, or even in different countries. As your business is growing, you need a separate store for a specific brand or country, but still, have the ability to fulfill and manage inventory from one system.  That means that you need an eCommerce […]

By Dejvid Haxhiu

Imagine you have a multi-brand business that has many stores around the city, country, or even in different countries. As your business is growing, you need a separate store for a specific brand or country, but still, have the ability to fulfill and manage inventory from one system.  That means that you need an eCommerce platform that comes out of the box with multi store functionality. Among the numerous eCommerce platforms and CMS’s in the market, Magento is one of the best solutions for multi-store functionality. This article will focus on Magento 2 multi-store functionality since it will be the only Magento version supported in 2018. 

Before diving into how to set up a Magento 2 multi store first let’s go over the concepts of Websites, Stores, and Store Views in Magento 2.

What is each of them and what are differences between them?

Websites

A website is the main concept of a multi online store. We can create multiple domains that point to the same Magento 2 folder. These domains can have different languages and catalogs, all running from the same or single Magento website/database. Technically a website is the main URL, domain, or subdomain of the store. For example, if we have a website named MyDomain.com and then have store.mydomain.com, mydomain.bix, my domain.net, mydomain.us all these of these websites can be nested under the main website (MyDomain.com), be all in separate languages, and run from the same database, and share the full or in part catalog of MyDomain.com. By creating a new website you have the ability to maintain a different base of customers, orders, prices etc from you main store.

Stores

A store in Magento 2 is a child of a website. One website can have multi stores as children. The store is the level where the Catalog it’s managed. That means you can have different products and categories in different stores. The customers are shared on all the stores that belong to a specific website.

Store Views

In general, a store represents the frontend of your website. That means can you can setup a different layout, design, or language on different store views The catalog structure per store view will always be the same, it simply allows for multi presentations of the data in the front.

 

Websites
  1. Possible to maintain a separate customer base for the website, or can share the customer accounts with all websites
  2. Difference base currency can be defined
  3. Different order base can be maintained
  4. Different prices can be given for the website using a configuration setting or can share the price globally
  5. Different Website URLs can be used or can share the same website URL (Magento keeps unique cookies)
Stores
  1. Customer accounts are shared among all the stores under a specific website
  2. Same base currency
  3. Same Price
  4. Product can be assigned store specifically
  5. Can have different root category configuration
Store Views
  1. Common practice is to distinguish between different language views for store
  2. Different display prices
  3. Category settings can be different
  4. Same root category for all store views

 

Setting up Multi Stores on Magento 2

 

NOTES:

  • It is better for the setup to be done before importing the catalog on the store. This is because you will need to edit every product to show on a different website you have already created. It will be a real pain if you have too many products.
  • Inventory is global across all the websites and stores. Either the product is IN STOCK or not! If you need different inventories,you have to use third party modules
  • We strongly recommend to plan out your website structure before you start actually adding items, so that you ensure you are building a nice logical system that is going to scale up as you grow
  • On the following tutorial, we will create a wholesale store with a new website, store, and store view.

 

The first step is setting it up on Magento admin.

  1. Login into Magento 2 admin, and go to Stores->All Stores. There you will see the Stores grid and three buttons above it. If dont have a store yet, you will see just one row on the grid including Main Website, Main Store and The Main Store View which are default in Magento 2.
  2. The first thing to do it’s to create a new website. Click on the Create Website and you’ll see the following fields
      1. Name – The Front name of the website
      2. Code –  The identifier of the website
      3. Sort Order – The order it will show on the store lists

    multistore_magento2

Click Save Web Site after filling the required fields.

The next step is to create the Store. Again on the Stores grid page now click Create Store. The fields there are:

    1. Website – Here you select the website you want to associate this store with
    2. Name – The front end name of store
    3. Root Category – Like we mentioned previously the store is the level that separates the Catalogs for each website. So on this field, you select the root category you want for your store. By default, Magento as one root category called Default Category. You can create a new one if you want. All of the subcategories of the root one will show on that website/store.

multistore_magento2

To finish with the store creation the last step is to create the Store View. On the stores grid now click on Create Store View. You will have to fill the following fields.

    1. Store  – Here you select the Store in which this store view applies.
    2. Name – The front name of the Store View
    3. Code – The identifier
    4. Status – Enabled/Disabled
    5. Sort Order – The order in the store lists.

The last step in the admin for setting up a new Magento 2 store is to specify the URL’s for the new store. You will need to create a subdomain or buy a new domain for your store. To add the new store domain in the admin go to Stores->Configuration->General tab-> Web.
The fields are Base Url and Base Url Secure. But as you can see, there will be your base store URL’s setup already there.
How to change them only for your new store? On every config/edit page in Magento you will see a Store View option in the top of the page. 

multistoremagento2
The default value set on it is the Default Config. There you can select the website, store or store view you want to modify.

But before selecting the scopes you want, you need to make sure that the config/attribute you are modifying is applied in the store level. You can check that on the side of each config/attribute. For the base URL we want to modify it like below:
multistore_magento2
The Store URL is in Store View level. Since the Store View it’s the lowest level in the store you can choose each level you want that is above it(website/store). Choose one of the stores to get to the configs of the new store. You will notice that the fields are not available for editing and them are filled with Default Config Scope value. To be able to edit the fields just uncheck the box on the right of the field you want to edit. 
multistore_magento2
Do that for the base URL field, put your new store URL there and save the configs.

This is all you need to do on the admin part to get a second store online.  There is also one thing that needs to be done on the .htaccess file to be able to access your new store URL but that’s too technical and it can be done by your server provider or developer.

 

Setting up a different design for your new store

Above we discussed how to setup different catalogs, product attributes, and configs for the new store. Now let’s see how can we create a new design for the second Magento 2 store. We first need to create a new theme or if you want a completely different front-end, either design and build a custom theme or buy a new template/theme for your second store and install it.

After installing/creating the new theme on the admin go to Content -> Design->Configuration. There you will see the following grid

magento_multistore2

The rows you see there are dependent on the scopes. The first row will always be the Global scope. By editing this row the changes will be applied on all websites you have set up.

For each Store you have created you will see 2 rows on this grid. The first one is the website scope of the store and the second one is the Store View Scope.
That is because like we have mentioned the frontend is managed on the website and store view scopes.

If your store has more than one store view you will see another row for that store on the grid. So to have a different design for your new store you just go and click the edit link on the last column in the grid. The row you click it depends on the which scope you want to have a new theme. If you want to apply the new theme to the whole new store you need to click the Edit link on the website scope of that store. This is the row the has empty columns for Store and Store View on that Website. By doing so, all the store views included on that website will be updated automatically after you save the changes.

That is what I have done with my wholesale store I created. As you see on the above image rows 4 and 5  have a new Theme Name. I edited the 4th row like below

magento2_multistore

If you have more than one store view applied on a website, for example, you have website2 store view row on the grid and you want different designs for different store view then edit the row of the website and the store view name.

This last step is optional if you want a different language for your new store.

        Go to Stores->Configuration->General tab->General->Locale Options. Change the scope to your new store like we did when adding the base URL.

Uncheck the Use Config box on the right of the Locale field and then select the language you want and then save.

In general, this is pretty much what Magento 2 offers for setting up multi stores. The idea is the same also on Magento 1 with some minor admin changes.

Back End Developer