Create and Configure Multi Store In Magento 2
Magento 2 comes with many new updates and improvements for merchants and developers .One of new features is Multi Store function.There are some different when set up multi store between Magento 1 and Magento 2 because of the change in file system in Magento 2. Today, we would like to share with you a blog post about Guide to Create and Configure Multi Store In Magento 2.
Under “All Stores” you can see three options “Create Website”, “Create Store View”, “Create Store”. First click on Create Website Button.
In the name field, enter your second store name
In code field, enter your second store code name (Be sure to remember your second store code)
Now click on Create Store for your second store website and those you created before. Click on “Create Store” option.
In “Web Site” option select your Magento 2 website
In “Name” field enter your Magento 2 store view name
In “Root Category” select “Default Category” and click on the “Save Store” button.
After creating store now create store view for your Magento 2 second store. Click on “Create Store View”
In “Store” field select your Magento 2 store
In “Name” field enter your Store View Name
In “Code” field enter code those you enter in “Create Website”
After this, click on “Save Store View” button. And now we connect our second store domain with new store that we have just created. Go to Stores > Settings > Configuration
Under “Configuration” select your second store in “Store View” option, the one you see on top
Your store is now set-up successfully at the back-end of Magento 2. Now set values for MAGE_RUN_TYPE and MAGE_RUN_CODE by using the following code in your index.php entry point:
<?php
$params = $_SERVER;
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'yourcode.yourdomain.com';
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'website';
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params);
$app = $bootstrap->createApplication('Magento\Framework\App\Http');
$bootstrap->run($app);
?>
<?php
$params = $_SERVER;
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'yourcode.yourdomain.com';
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'website';
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params);
$app = $bootstrap->createApplication('Magento\Framework\App\Http');
$bootstrap->run($app);
?>
For setting up SetEnvIf, add following code in your .htaccess file after “RewriteEngine on” this:Save your index.php file. After this set values in .htaccess file. This section discusses to set values for MAGE_RUN_TYPE and MAGE_RUN_CODE for using Apache Server Variables SetEnvIf or RewriteCond.
SetEnvIf Host .*example.com.* MAGE_RUN_CODE=yourcode.yourdomain.com
SetEnvIf Host .*example.com.* MAGE_RUN_TYPE=website
For setting up RewriteCond, add following code in your .htaccess file after “RewriteBase /magento/” This:
RewriteCond %{HTTP_HOST} ^(.*)example\.com
RewriteRule .* – [E=MAGE_RUN_CODE:yourcode.yourdomain.com]
RewriteCond %{HTTP_HOST} ^(.*)example\.com
RewriteRule .* – [E=MAGE_RUN_TYPE:website
More Magento 2 tutorials :Save your .htaccess file.RewriteCond %{HTTP_HOST} ^(.*)example\.com
RewriteRule .* – [E=MAGE_RUN_CODE:yourcode.yourdomain.com]
RewriteCond %{HTTP_HOST} ^(.*)example\.com
RewriteRule .* – [E=MAGE_RUN_TYPE:website









Nhận xét
Đăng nhận xét