Contact
Site: US UK AU |

How to configure multiple Magento storefronts

How to configure multiple Magento storefronts 

Overview
This article demonstrates how to use Magento configure multiple storefronts for a single website.

Once you have created your new store, you can choose from either of the two different methods presented in this article for implementing multi-store functionality at the server level:

Purpose

A Magento storefront is the customer-facing view of a Magento eCommerce website. A Magento website may consist of one or multiple storefronts. These storefronts manage showcase products, categories, and search functionality. It is possible to configure multiple Magento storefronts for the same website. Explore the Magento website for more information.

Creating a storefront 

The first step in setting up multi-store functionality is to create the new store or stores in the Magento administrator application. Follow the steps below to create a new store:

  1. Log in to the Magento Admin Panel. If you want your stores to share the same catalog and products, skip to Step 7.
  2. In the top menu, go to Catalog > Manage Categories.
  3. Click Add Root Category (Figure 1).


    Figure 1. Add Root Category button.

  4. In the Name field, enter your new store name.
  5. Under Is Active, select Yes.
  6. Under  Display Settings, in Is Anchor, select Yes, and select Save Category (Figure 2).


    Figure 2. Save Category button.

  7. Go to System > Manage Stores.
  8. Click Create Website.
  9. In the Name field, enter your new store name.
  10. In the Code field, enter a unique string without spaces and click Save Website (Figure 3).  Write this code down so you may use it later.


    Figure 3. Save Website button.

  11. Click Create Store.
  12. In the Website field, select the website that you just created.
  13. In the Name field, type a name for your store.
  14. In the Root Category field, select the root category that you created above or use the default Root Category if you skipped ahead. Click Save Store (Figure 4).


    Figure 4. Save Store button.

  15. Click Create Store View.
  16. In the Store field, select the store you just created. In the Name field, give your view a name. This is typically "English."

  17. In the Code field, enter a unique string to identify the store view. Change the Status to Enabled. Click Save Store View (Figure 5).


    Figure 5. Save Store View button.

  18. Go to System > Configuration.
  19. In the Current Configuration Scope drop-down list (Figure 6), select the website that you just created.


    Figure 6. Current Configuration Scope drop-down list.

  20. Select the Web menu option, and click to expand the Unsecure and Secure sections, respectively.
  21. For each section, clear the Use Default check box next to the Base URL and type the URL for your store, including the trailing slash. Click Save Config (Figure 7). 


    Figure 7. Save Config button on upper right.

  22. You have successfully set up a Magento store. Repeat the steps above for any additional stores you wish to create.

Configuring the server to load the storefront

After store creation, you must configure the server to load the correct store. There are several methods for doing this. The two most popular methods are presented below. The first method is the older of the two and will work for any version of Magento. The second method takes advantage of changes made to the index.php file introduced in version 1.4.0.1.

Method 1: Using separate directories for each store using secondary domains

  1. Verify your chosen domain name points to the server.
  2. Follow the instructions provided in How to create a secondary domain to create a secondary domain for your new store.
  3. Using either FTP or SSH, copy the .htaccess  and index.php files from your Magento installation to the document root of your new domain.
  4. Open the index.php  file that you just copied over and edit the last line of the file as follows:
    Attention: Change newstore to the code that you wrote down when you created the new website above.

    Mage::run('newstore','website');

  5. Finally, using SSH, create the following symbolic links in the document root of your new domain, and replace the path below with the full path to the document root of your Magento Installation:

    ln -s /home/example/example.com/html/app/ app
    ln -s /home/example/example.com/html/includes/ includes
    ln -s /home/example/example.com/html/js/ js
    ln -s /home/example/example.com/html/lib/ lib
    ln -s /home/example/example.com/html/media/ media
    ln -s /home/example/example.com/html/skin/ skin
    ln -s /home/example/example.com/html/var/ var
    ln -s /home/example/example.com/html/404/ 404 # this is only in 1.3x
    ln -s /home/example/example.com/html/reports/ reports # this is only in 1.3x


  6. You have successfully configured your secondary domain to work with Magento. You may now load your new domain in your browser and begin developing your new store.

Method 2: Using shared directory for all stores using pointer domains

If you are configuring a multi-store on a server running the PHP-FPM service and use the pointer domain method outlined below, you will likely require support from the Nexcess Support Team. We will adjust the server's Apache vhost configuration file to properly redirect your site to the correct store front. We generally refer to this as the "FPM fix," and we suggest contact the Nexcess Support Team to request this fix if you are experiencing issues with your Pointer Domain multi-store on a PHP-FPM server.

These instructions will work only for Magento versions 1.4.0.1 and higher.

  1. Ensure your desired domain name is pointing to the server.
  2. Follow the instructions provided in How to create a pointer domain to create a server alias pointer domain for your new store. The pointer domain will be pointing at the primary domain of your Magento installation.
  3. Edit the .htaccess file in the document root of your Magento installation and enter the following just above the line RewriteEngine On:
  4. Replace .*newstore.* with the domain name of your new store, keeping the dots and stars.
  5. Ensure that MAGE_RUN_CODE matches the code you wrote down when you created the new website above. Newstore specifies the domain name of your new store, and websitecode specifies the store code created in Magento.

SetEnvIf Host .*newstore.* MAGE_RUN_CODE=newstore

SetEnvIf Host .*newstore.* MAGE_RUN_TYPE=website or store

      6.  You have successfully set up your pointer domain to work with Magento. You may now load your new domain in your browser and begin developing your new store.

Addendum: if SetEnvIf fails

On some servers, particularly those running Litespeed Web Server, the SetEnvIf directive does not get recognized in the .>htaccess file. If method 2 fails to configure multiple storefronts, try the following:

  1. Edit the .>htaccess file in the document root of your Magento Installation.
  2. Type the following text just below the line #RewriteBase /magento/:
    • Verify .*newstore\.com matches the domain name of your new store.
    • Verify MAGE_RUN_CODE matches the code you wrote down when you created the new website above.

    RewriteCond %{HTTP_HOST} .*newstore\.com [NC]
    RewriteRule .* - [E=MAGE_RUN_CODE:newstore]
    RewriteCond %{HTTP_HOST} .*newstore\.com [NC]
    RewriteRule .* - [E=MAGE_RUN_TYPE:website]

     

    For 24-hour assistance any day of the year, contact our Support Team by email or through the Client Portal.

Article Rating (17 Votes)
Rate this article
  • Icon PDFExport to PDF
  • Icon MS-WordExport to MS Word
 
Attachments Attachments
There are no attachments for this article.
Related Articles RSS Feed
How to disable caching in Magento
Added on Tue, Nov 5, 2013
How to enable the Magento profiler
Added on Thu, Feb 25, 2016
How to set the return-path email in Magento
Added on Thu, Oct 30, 2014
What are the benefits of dedicated IP addresses?
Added on Thu, Jan 14, 2016
How to patch your Magento store
Added on Mon, Jan 11, 2016
How to configure the Magento Product Importer (Magmi)
Added on Mon, Jan 26, 2015
How to enable CAPTCHA for user creation in Magento 1.x
Added on Fri, Aug 18, 2017
How to change Magento base URLs
Added on Tue, Jun 12, 2018
How to improve the security of your Magento store
Added on Wed, Nov 12, 2014
What is Varnish?
Added on Thu, Aug 28, 2014