The Magento platform provides an amazing built-in feature for creating multiple stores in a single administration that helps to launch multiple web store views to expand your business internationally for achieving business goals and growing brands. Many people don’t know how to setup multiple stores that’s why in this blog, we are going to explain how to setup multiple stores in Magento 2 platform.
Here 5 steps to setup Magento 2 multistore:
Step 1: Go to Catalog in Magento 2 admin and Create a Root Category in Catalog>Category
Step 2: Go to Store > setting > all store and Create a new website
Step 3: Create a new store
Step 4: Create store views
Step 5: Configure the Store URL for multiple stores
Step 6: Editing the index.php file
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
<?php use Magento\Framework\App\Bootstrap; try { require __DIR__ . '/../app/bootstrap.php'; } catch (\Exception $e) { echo <<<HTML <div style="font:12px/1.35em arial, helvetica, sans-serif;"> <div style="margin:0 0 25px 0; border-bottom:1px solid #ccc;"> <h3 style="margin:0;font-size:1.7em;font-weight:normal;text-transform:none;text-align:left;color:#2f2f2f;"> Autoload error</h3> </div> <p>{$e->getMessage()}</p> </div> HTML; exit(1); } function isHttpHost($host) { if (!isset($_SERVER['HTTP_HOST'])) { return false; } return $_SERVER['HTTP_HOST'] === $host; } $code = "base"; $type = "website"; if (isHttpHost("dev.webiators.com")) { $code = "base"; $type = "website"; } if (isHttpHost("fashion.com")) { $code = "fashion_store"; $type = "website"; } $_SERVER[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = $code; $_SERVER[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = $type; $params = $_SERVER; $params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]= $code; $params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE]= $type; $bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params); $app = $bootstrap->createApplication('Magento\Framework\App\Http'); $bootstrap->run($app); |
Step 7: flush the Magento 2 cache
Go to System > Tools > Cache Management and click Flush Magento Cache.
Hope this blog post will be very helpful for you!
Thank You!