Magento Multistore Tutorial

How to configure your Magento application to work as a Multistore

This tutorial covers the following topics:

The primary use of the Magento multistore functionality is to create multiple stores accessible on different URLs under the same Magento installation. All stores under the Magento multistore installation share the same backend, which makes the administration easier.

The first step in setting up a multistore is to open up the Stores > All stores menu under Settings.

This would open up the available stores on your website. To add a new one, click on the Create Website button.

You would be redirected to a new page where you have to add the new website's information.

  • Name - here you should add the new website's name;
  • Code - this will be the web site's code and you should make sure it is a unique string;
  • Sort order - this field is optional and inidicates the order of your store’s priority.

When you fill in the necessary information - click on the Save Web Site button. This would get you back to the Stores screen where you should click on the Create Store button now.

This would take  you to a new page where you should specify your store's details.

  • Web Site - here you should select which website will be used for the new store. For the purpose of this tutorial we will be using the My second website web site;
  • Name - in this field you should input your store's name;
  • Code - this will be the store's code;
  • Root Category – here you may choose a category that the newly created store would show.

When ready, click on the Save button and you would be redirected to the stores page again.

There you may see that the newly create store was successfully assigned to the website.

The next step would be to create the Create Store View by clicking on the corresponding button.

This would open up the store view addition page where you should fill in the following details:

  • Store - the store to which we want to assign the view
  • Name - the store view name
  • Code - this will be our store view code
  • Status - choose to disable or enable the store view
  • Sort order - this field is optional and indicates the order of your store view’s priority.

When ready, click on the Save Store View.

Then you should make sure to change the new store's URLs via Stores > Configuration under Settings > expand General > Web. After that from the drop down for store view choose the newly created store and update its URLs accordingly.

The next step is to configure the changes on the server.

Addon Domain Method

This method may be useful to you if you want to have a blog on one of your stores and not on the others.

To use the Addon Domain method, you need to add your domain as an addon domain through your cPanel. This will create a separate document root directory for that domain. By default, cPanel will name the directory with the same name as the domain. In this case, it will be addondomain.com and it will be inside the public_html folder.

Once the domain is added, you need to establish an SSH connection to your account. Once connected, go to the directory that we previously created for the addon domain. In our case, the command is:

Copy the index.php and the .htaccess files of your Magento installation to that directory:

Open the new index.php file replace the following code:

with

where StoreID should be replaced by your store's ID number. You may lookup your store's ID when you go to Stores > All stores and open up the desired Store view. You would notice the following part of the URL:

In this case the store ID is 2. If the store ID is 3, the aforementioned part in the URL would be /store_id/3/.

Once you add the code, save the file and close it. The last step is to create symbolic links that will point to the core Magento directories. You could do that by executing the following commands in the document root directory of your addon domain:

Note that depending on where the document root directory of your domain is, the path in the commands may defer. Once the links are created, clear the cache of your Magento and you should be able to access the newly created store with its domain name.

Subdomain Method

The setup of that method is the same as the Addon Domain Method with the exception that this method uses subdomains instead of addon domains. You could add subdomains through your cPanel. Once the subdomain is added, follow the same steps described above.

Parked Domain Method

In order to use that method, first you need to add your domain as a parked domain through your cPanel.

Once the domain is added, open the index.php file of your Magento and find the lines with the following code and remove them:

On their place input the following lines:

In the above code you should make sure to substitute the yourmainstore.com with your store's domain, and yoursubstore.com - with the parked domain which will be your sub-store. Also, the StoreID should be replaced by your store's ID number. You may verify your store's ID when you go to Stores > All stores and open up the desired Store view. You would notice the following part of the URL:

In this case the store ID is 2. If the store ID is 3, the aforementioned part in the URL would be /store_id/3/.

That's it. You Magento multistore should be functioning as expected now.