Setting up Multiple Stores with Magento

Posted on

Magento out of the box has many features such as the multi-store (multiple front-ends, one back-end) system which we are going to use today. This can easily transform a single website into multiple stores, for example you could split one big store into: one store for toys and games, one store for electronics and one store for clothes. Each of those stores could have different currencies and languages, all controlled from one admin panel, so as you can see Magento is very flexible.

Choosing a URL Structure

First of all we need to decide on our URL structure of the new store. For example, we could choose between the following 3 options:

  • my-store.com/new-store
    (setup the new store in a new directory on your existing domain)
  • my-new-store.com
    (setup the new store on a new domain)
  • new-store.my-store.com
    (setup the new store on a sub-domain of your existing domain)

Once you’ve decided on your URL structure for your new store, we can learn the Magento Structure for this.

What is the Magento Multi-Store Structure?

Magento uses 3 different types of stores with multiple stores. I will briefly cover them here for your understanding before we continue:

  • Website – At the most root level, we can have multiple websites, which contain the stores. These website can be set-up to share customer data or not share any data at all.
  • Store – these are the “children” of a Website. The catalog (Products and Categories) are managed at this level.
  • Store View – these are the “children” of a store, it uses the catalog of the store but displays it based on the store view. So you can offer different language versions of your store for example.

See the diagram below to illustrate some example stores in the Magento Multi-Store format:

Example of multi-store front-end's with one Magento back-end

Example of multi-store front-end’s with one Magento back-end

Creating a new store in Magento

Now we can set-up our new Magento Store in the Admin Panel, this is fairly straight forward:

  1. First of all you will need to log-in to the Magento Admin Panel.
  2. Then Select “Manage Categories” from under the “Catalog” section on the top navigation menu.
  3. Press the “Add Root Category” button on the left-hand side.
  4. Now fill out your Category Name (your new store name) and ensure you set both “Is Active” and “Is Anchor” to Yes in the category settings before saving.
  5. Once saved, then on the top navigation, select System > Manage Stores.
  6. Press the “Create Website” button.
  7. Fill out your new website name e.g. “New Store Website”, and assign a code for your website, such as “mystore” – remember this value as we will need it later.
  8. Once your new website is saved, Press the “Create Store” button.
  9. Select the website you’ve just created from the drop-down, select the root category you’ve also just created from the drop-down and then give your store a name, e.g. “My New Store”.
  10. Once your store is saved, Press the “Create Store View” button. Select the store from the drop-down you’ve just created and give the Store View a name, e.g. “My New Store – English”, so you could create a code such as “mystore_en”. Ensure the Status is “Enabled”. Now save your store view.
  11. Now for the final steps, we need to set-up your decided URL config for your new store. Go to System > Configuration in the top navigation of your admin panel.
  12. Change the current configuration scope (in the top left corner) to select your new store website that you created.
  13. When the page has reloaded, select “Web” from the left-hand side navigation.
  14. For both the unsure and secure configuration sections, you will need to uncheck the box named “Use Default” which resides beside the “Base URL” input boxes.
  15. Then you will need to change your Base URL’s, to your new website URL, e.g. http://www.my-new-store.com/ (always include a trailing slash, otherwise it won’t work correctly).
  16. Press the “Save Config” to complete the process.

You have now successfully set-up your Magento Admin Panel to work with your new Magento Store.

Configure your hosting for the New Store

This stage is more technical, and will require FTP access, SSH access and basic code editing skills. You should ask your Magento web development company to do this for you.

Within your FTP/SSH, you will need to ensure you have access to both the existing Magento Installation location and the path to your new domain, folder or sub-domain directory.

  1. Firstly you will need to created “Symbolic Links” within your new path directory for your new store, so it links to the files in your existing Magento installations. So if your Magento Installation is in a folder called “public_html” and your new store is in a folder called “public_html_newstore”, we can use the following commands via SSH to set-up the symbolic links:[pyg language=”bash”]
    ln -s ../public_html/app ./app
    ln -s ../public_html/errors ./errors
    ln -s ../public_html/includes ./includes
    ln -s ../public_html/js ./js
    ln -s ../public_html/lib ./lib
    ln -s ../public_html/media ./media
    ln -s ../public_html/skin ./skin
    ln -s ../public_html/var ./var
    [/pyg]
    Running those commands from within your new store folder, will link the above folders from your main installation so they can used on your new store.
  2. Next you will need to copy your index.php and .htaccess from your Magento Installation into the root your new folder. You can do this with SSH also using the following command:[pyg language=”bash”]cp ../public_html/index.php ../public_html/.htaccess .[/pyg]
  3. You will then need to edit your index.php file so it runs your new Magento store instead of your existing one. Firstly you need to update the path to Mage.php, so replace this line:[pyg language=”php”]$mageFilename = ‘app/Mage.php’;[/pyg]
    with:[pyg language=”php”]$mageFilename = ‘../public_html/app/Mage.php’;[/pyg]
    now find:[pyg language=”php”]Mage::run($mageRunCode, $mageRunType);[/pyg]
    and right before it, add (replacing “mystore” with your new website code):[pyg language=”php”]
    $mageRunCode = ‘mystore’;
    $mageRunType = ‘website’;
    [/pyg]

And that’s it, your Magento store is ready to go. Let us know how your set-up went in the comments below, if you need help from a Magento Specialist, get in touch and we’ll be gladly able to assist you with your multi-store Magento e-commerce development project.

 

Want to discuss a project?

Talk to our Magento experts on 01785 279920

Request a callback