How to set up multiple websites, stores, and store views in Magento 2?
Magento allows us to set up and manage multiple instances of stores or domains in a single Magento backend. In this section, we will go through with how to set up multiple websites, stores, and store views in Magento 2.
Establishing multiple stores in a single Magento 2 backend is one of the variable functionalities that Magento 2 brings to store owners. This feature allows us to create several stores as many as we need in a single configuration. All the stores share the same domain, are set up as subdomains of the same domain, or have a completely different domain, yet possibly share the same backend for the easy administration.
Step 1: Create websites
1. In the Magento 2 Admin panel, Go to Stores >> Settings >> All Stores.
2. Stores page will appear in front of you, click on the Create Website.
3. Enter the required information in the given field, such as Name, Code, and Sort Order, and click on the Save Website button.
4. Now, we can see that the website is created, which is visible on the Store page below the Main Website. Repeat these steps as many times as necessary to create your website.
Step 2: Create Stores
1. In the Magento 2 Admin panel, Go to Stores >> Settings >> All Stores.
2. Now, on the Stores page, click on the Create Store button to create the store.
3. Fill the required information in the given fields follow the below instructions:
a. Select the website from the drop-down list, which is the parent of the new store. If there is only one website, then use the default, i.e., Main Website. Here we will select the Expert, which we have created in previous steps.
b. Enter the Name of the new store, just for the internal reference.
c. In the Root Category field, select a category for the main menu of the store. We will select Default Category here.
After completing the details of the store, click on the Save Store button.
4. Now, we can see that the Store is also created, which is visible on the Store page below the Main Website. Repeat these steps as many times as necessary to create your store.
Step 3: Create Store Views
1. In the Magento 2 Admin panel, Go to Stores >> Settings >> All Stores.
2. Now, on the Stores page, click on the Create Store View button to create the store view for your store.
3. Fill the required information in the given fields.
a. Select the store from the drop-down list to associate this store view.
b. Enter the name in Name field to identify this store view.
c. Provide a unique name in the Code field to identify this store view.
d. Set the status to Enabled.
e. Enter an optional numerical sort order.
Now, click on the Save Store View button to save the new store view information.
4. A pop up will open while saving the store view information. Click on OK and move ahead.
5. Repeat the steps as many times as necessary to create the store view. In the below screenshot, you can see that the Store view is created for your new website and store.
Step 4: Setup the Store URL
In this step, we will configure the Store URL.
1. On the left sidebar of Admin Panel, Go to Stores >> Settings >> Configuration.
2. Here, select Web under the General tab.
3. Expand the URL Options section and set Yes to Add Store Code to URLs field and save. Therefore, wherever we will switch the store, the store code will come automatically appended with URL.
4. On the upper left corner, select the Store View to check the new store that we added. From the Store View list, choose a website. We can get the information by selecting any store from the Store View drop-down list.
Click on OK to verify the scope switching.
5. Now, expand the Base URLs section. Clear the Use Website checkbox, which is next to the Base URL field, and change the Base URL for the store. For example – https://subdomain.example.com/
6. Open the Secure Base URLs section and set the store’s secure URL if needed.
Click on the Save Config button at the top of the page to complete.
In case, you have created the store and store view under Main Website similar to the below screenshot. Then follow the below instruction.
Clear Cache Management
On the Admin Panel, Go to System >> Tools >> Cache Management.
Select all from the drop-down list, and click on the Flush Magento Cache button.
Now, open the frontend and reload the webpage. Here, you can switch from one store to another store by clicking on the sub-domain of the Main Website Store. See in the below screenshot.
The new store is: