How to create & configure magento 2 multistore
Among the many services that are offered by the software, Magento 2 Multistore might perhaps be one of the most beneficial facilities yet. The Magento 2 Multistore can be of benefit to the shop owner who wishes to 1) expand their business, 2) program a single administrator in such a way that it can manage multiple stores at once, or 3) set up stores in multiple locations. The many uses of using Magento 2 multistore, are listed below:
- Saving costs by using a single payment gateway in all the stores
- Using third-party extensions and integrations can help achieve unified support for all of the stores that have been created
- A single, common customer database can be retained for usage in all the stores that have been created
- It will prove very useful when dealing with responsive frameworks
You can create as many stores as you need with the Magento 2 Multistore setup feature in a single configuration.
HOW TO SET UP MAGENTO 2 MULTISTORE
STEP 1: You can start setting up by first creating a new website
LOG IN to the Magento Backend. Proceed to STORE, and choose ALL STORES from the SETTINGS option (Store > Settings > All Stores). Once on this page, go ahead and click the CREATE WEBSITE button. Here, you would be asked to fill 3 spaces:
- Name: Your website name is to be entered here
- Code: The unique code for your website is supposed to be entered here
- Sort Order: This field is optional. The maximum value is already set to 0 by default.
When you are done with these steps, you can SAVE the website.
STEP 2: In step 2 of setting up a Magento 2 multistore, you can now proceed to create a new store.
Begin by navigating to STORE, followed by SETTINGS, and then finally click on ALL STORES like in Step 1. On the STORES page, click CREATE STORE. Here, you can:
- Choose a website by choice
- Name your store
- Choose the ROOT CATEGORY that would be displayed within the store. You can follow the following steps to add a NEW ROOT CATEGORY:
- You can go to CATEGORIES under PRODUCT (Product > Categories)
- Navigate to the left column of the page and click on the ADD ROOT CATEGORY option
- You can now choose and select a CATEGORY NAME to enter here, and then SAVE the changes once you enable the category.
Now, go ahead and SAVE the store.
STEP 3: Create a new store view for the Magento 2 multistore
Like in steps 1 and 2, begin by navigating to STORE, followed by SETTINGS, and then finally click on ALL STORES like in Step 1. On the STORES page, click CREATE STORE VIEW. Once here,
- Go ahead and pick a STORE as per your liking
- NAME the said Store View
- ENABLE the status
The STATUS section is optional. Its maximum value is already set to 0 by default. You can now go ahead and SAVE the Store View.
STEP 4: this is the step where you would check for Mode and Access permissions. Please note, however, that only beginners would need to give attention on this step. This is essential for developer mode enabling.
- Grant permissions to the directories mentioned below:
chmod -R a+wX var
chmod -R a+wX app/etc
chmod -R a+wX pub
- In order to change a mode, you can use this command:
bin/magento deploy:mode:set developer
Another way to do that, is by going to APP/ETC/ and opening ENV.PHP; from here, you can change the existing mode of application by MAGE_MODE’ => ‘DEFAULT’ to MAGE_MODE’ => ‘DEVELOPER’.
STEP 5: In step 5 of setting up a Magento 2 multistore, you can now proceed to create a new website.
Start by making a new folder from your root directory. Now, from the Magento root directory, copy the INDEX.PHP file and .HTACCESS file to the new made directory for the newly made website within the Magento root directory. Now, you can replace the INDEX.PHP code into the code snippet provided below:
require 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’);
Then, proceed to ADMIN. From there, you can open SETTINGS from STORES. On the settings page, you would find CONFIGURATION. From there, you can continue to CONFIGURATION > GENERAL > WEB. After that, choose a website from the section at the top of the page labelled “Store View”. Make sure choose a website that is not the default website. Then, expand the BASE URLs in the right panel and unselect USE DEFAULT. You can fill up the required fields as explained below:
- Base URL: the base URL goes here
- Base Link URL: the base link URL goes here
- Base URL for static view files (default value): the URL for static view files should be entered here
- Base URL for user media files (default value): the URL for media files is to be added here, and also in the fields mentioned under BASE URLs (secure) if they are required for an ‘https’ access.
STEP 6: You can now SAVE CONFIGURATION for Magento 2 multistore
STEP 7: for CACHE MANAGAEMENT, you can go to SYSTEMS, and then proceed to TOOLS > CACHE MANAGEMENT, and then go ahead and press the FLUSH MANAGAEMENT CACHE option.
STEP 8: by this point, you should be able to see the multiple store views and stores within your web browser if the corresponding URLs are entered.
STEP 9: By using the SSH, you can replace the path below with the whole path to the document root of your Magento installation when creating the following symbolic links in the document root of your new domain:
ln -s /home/example/example.com/html/app/ app
ln -s /home/example/example.com/html/lib/ lib
ln -s /home/example/example.com/html/pub/ pub
ln -s /home/example/example.com/html/var/ var
STEP 10: At this point in your process for setting setting up a Magento 2 multistore, your new domain should load in your browser once you’ve successfully set up your secondary domain to work with Magento, allowing you to start building your new store.
So in conclusion, a Magento 2 multistore may prove to be an e-store owner’s dream come true for business expansion and growth.