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 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?
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.
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.
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.
Setting up Multi Stores on Magento 2
- 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.
- 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.
- The first thing to do it’s to create a new website. Click on the Create Website and you’ll see the following fields
- Name – The Front name of the website
- Code – The identifier of the website
- Sort Order – The order it will show on the store lists
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:
- Website – Here you select the website you want to associate this store with
- Name – The front end name of store
- 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.
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.
- Store – Here you select the Store in which this store view applies.
- Name – The front name of the Store View
- Code – The identifier
- Status – Enabled/Disabled
- 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.
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:
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.
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
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
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.