How To Setup And Manage Domains and Multiple Stores In Magento.

setup-manage-multiple-stores

Magento‘ is a handy and flexible eCommerce framework, empowered to manage various different front-ends & stores having multiple domains with one dashboard.

As per your need, you can configure a Magento installation depending upon its setup by spreading out multiple sub-domains amongst different stores, that can be managed with a single admin. All these stores can even share customers, settings and common product catalogs.

This multisite-multistore concept offers various benefits for you by creating and showing variants in the products, categories and CMS pages as per your store or website requirement.

Although, the methodologies discussed below apply irrespective of using any control panel, this blog is written keeping cPanel in mind and you may need to install Magento 1.4.x or higher version.

Whyย  you should go for Multiple Stores ?

  • Serving different customer sections with their different requirements (e.g. B2B and B2C)
  • Multiple brands having theirย  respective needs and identity
  • Targeting various customers to sell a number ofย  products
  • Selling in different countries with different currency, tax andย language.

What are the Features Offered By Magento?

Within a single installation, Magento offers various advanced features to your multiple websites and stores. Magento helps to structure the store as Website Domain, Stores and Store Views.

  • Websiteย – A Website usually can be set upย not to share any data or to share customer data and it may contain one or two stores.

  • Store โ€“ At store level, Products and its Categories can be managed to allow multiple stores within the one website and having entirely different catalog layout.

  • Store View โ€“ It allows multiple visualizations of the data and every store view for catalog structure will remain same. Store views allows customers to choose and switch between 2 or many languages.

As per your requirements, you can use a number of ways to setup and manage domains and multiple stores in Magento, shared with a single back-end and code-base.

Before proceeding further, first you should clearly understand the choice on how to address a store and its setup URL layout.

URL layout

It is a matter of your personal need and choice to structure the actual URL layout.

For e.g. two solely different stores operated on a single domain may share the same instance of Magento:

  • domain.com / trousers
  • domain.com / sweaters

Also, these stores could also be setup on their respective domain and sharing the same instance of Magento :

  • trousers.com
  • sweaters.com

Furthermore, in a mall type setup, you can access different stores with your primary domain as a portal:

  • mall.com
  • trousers.mall.com
  • sweaters.mall.com

Irrespective of the URL layout, the process of setting up these stores are same having a single code-base to run all stores, and a single back-end to manage all of these stores.

Adding Another Store

First of all, you need to setup your second store in Magento.

For e.g. you can assume to ownย  trousers.com.

Configure the required values accordingly for this store.

  • Logging in to the admin of Magento.
  • Go to theย Catalogย tab, and selectย Manage Categories.
  • On the left, Enter Add Root Categoryย tab.
  • On the right, enter trousers.com, set both the stores drop-down to ‘Yes’ for Is Activeย and Is Anchor.
  • Select the Save Categoryย tab.
  • Selectย Manage Stores by entering to theย Systemย tab.
  • Enter Create Website.
  • For Name, enterย ‘trousers.com' and for theย Code enter ‘trousers’.
  • Enter theย Save Websiteย tab.
  • Enter Create Store.
  • On drop-down, select trousers.com for Website. For theย Name,ย  enterย Main Store, and from the drop-down select the trousers.com, for theย Root Category.
  • Enter theย Save Storeย  tab.
  • Enter theย Create Store Viewย button.
  • From the drop-down, enterย Main Store, For theย Store. And confirm it’s for the trousers.comย website. Enterย English,For the Name, Enter trousers_en,for theย Code, From the drop-down, chooseย Enabled, for the Status.
  • Enter theย Save Store Viewย tab.
  • Choose Configuration by entering theย Systemย tab.
  • Alter the drop-down menu on Default Configย to trousers.com, theย Current Config Scopeย (located on the top left)
  • Under theย Generalย heading, from the left sidebar, chooseย Web.
  • Un-check theย Use defaultย box next to theย Base URLย products, for both sections with theย Secure and Un-secure. Enter URL, e.g.ย http://www.trousers.com/.
  • Enter theย Save Configย tab.

All above steps are essential to setup second store.

To set-up the store on the server-side for a convenient access to the visitors, you’ll need to choose the best one from the various processes discussed below :

Parked Domain Process

The Parked domain process is the easiest and fastest method, if you are choosing URL structure having each store with different domains. In this process, you’ll claim to have trousers.comย and sweaters.com. And trousers.com installed with Magento will be your primary domain.

Set up domain ‘sweaters.com'ย with following steps:

  • Enter Parked Domainsย icon, after logging to cPanel of your domain.
  • In the input field, enter the domain name to set-up second store.
  • Select and enterย Add Domainย tab.
  • In Magento index.phpย file find the line (the last line of the file):

Mage::run($mageRunCode, $mageRunType);

Add the following code right before this :

switch($_SERVER['HTTP_HOST']) {

case 'sweaters.com':

case 'www.sweaters.com':

$mageRunCode = 'sweaters';

$mageRunType = 'website';

break;

}

Are you owning more than two stores ?

If yes, then to the above block, add additional cases:

switch($_SERVER['HTTP_HOST']) {

case 'sweaters.com':

case 'www.sweaters.com':

$mageRunCode = 'sweaters';

$mageRunType = 'website';

break;

case 'sweaters.com':

case 'www.sweaters.com':

$mageRunCode = 'sweaters';

$mageRunType = 'website';

break;

}

Add-on Domain Process

This process takes a little longer time to setup, otherwise having the same scenario as above.

It might be more beneficial to you, if you planned to have a blog on one domain and not on another.

It couldn’t be possible with a parked domain.

Follow the below steps to set-up domain sweaters.com:

  • Enter theย Addon Domains, for your domain by logging to cPanel.
  • Enter sweaters.com, asย New Domain Name and automatically, cPanel will fill in the next two fields. From theย Document Rootย field, removeย public_html/ย and it will leave you with sweaters.com. Although, this step is not essentially required, still it makes more sense for organizational purposes.
  • After setting a password for this domain, enter theย Add Domainย tab.
  • Via SSH, login to your site and enter to the previously set directory in theย Document Rootย field while adding domain. e.g.:

cd sweaters.com/

  • From the directory installed with Magento, copy theย index.phpย andย .htaccessย file

cp ../public_html/index.php ../public_html/.htaccess .

  • Find this line (the last line of the file), after opening theย index.phpย file :

Mage::run($mageRunCode, $mageRunType);

Add the following code, right before this:

$mageRunCode = 'sweaters';

$mageRunType = 'website';

  • Finally, create symbolic links to point some directories:

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

Sub-domain Process

In this method, pretend to ownย domain.com. As a portal, this setup links to a number of shops within the mall. On theย domain.com, Magento will be installed and sub domains will carry all the shops e.g.:

  • trousers.mall.com
  • sweaters.mall.com

Follow the below mentioned steps to set up for theย sweatersย sub domain:

  • Enter theย Sub Domainsย icon, after logging in to cPanel for your domain.
  • Enter sweaters, for theย Sub Domain and cPanel will automatically fill in the next field. From theย Document Rootย field, remove public_html/ย to leave with justย trousers. Although, this step isn’t essential, it makes more sense for organizational purposes.
  • Enter theย Createย tab.
  • Via SSH, login to your site and enter the previously set directory in theย Document Rootย field above while creating your sub domain. e.g. :

cd sweaters/

  • From the directory installed with Magento, copy theย index.phpย andย .htaccessย file in root web directory:

cp ../public_html/index.php ../public_html/.htaccess .

  • Find this line (the last line of the file), after opening theย index.phpย file :

Mage::run($mageRunCode, $mageRunType);

Add the following code, right before this:

$mageRunCode = 'sweaters';

$mageRunType = 'website';

  • Finally, create symbolic links to point some directories:

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

Sub-directory Process

This process have the same scenario as above, except all the stores will be in sub-directories, e.g.:

  • domain.com/trousers
  • domain.com/sweaters

Learn with below mentioned steps, how to set up this for theย sweaters sub-directory:

  • Via SSH, login to your website to create a sub-directory for your second store:

cd public_html

mkdir sweaters/

cd sweaters/

  • From the directory installed with Magento, copy theย index.phpย andย .htaccessย file in root web directory:

cp ../public_html/index.php ../public_html/.htaccess .

  • Find the line (the last line of the file) after opening theย index.phpย file :

Mage::run($mageRunCode, $mageRunType);

Add the following code, right before this:

$mageRunCode = 'sweaters';

$mageRunType = 'website';

Multiple Stores Management.

As you are managing multiple stores with a single admin panel, so it is very important to make sure that you’re altering the configuration for the respective store.

You can globally change the configuration values of your all individual stores and websites in theย Systemย โ†’ย Configurationย section by leaving the drop-down menu forย Current Configuration Scopeย set toย Default Config, without removing the check-mark throughout the configuration sections next toย Use default.

Usingย ย  Multiple-Store In Magento

Presume, you are a sporting apparels company, who sells shoes, clothing for the customers of both formal and casualย  wears in multi-languages, then you might consider selling formal and casual apparels on their own website (either you can host these sites under a sub domain, a separate domain or a sub folder is altogether different).

Further, you might consider to create two different stores under the Footwear and clothing websites โ€“ one for Formals and another for Casuals.

Store views are generally used with the presented changes for the information, like a language.

Here, at store level you can configure various products, their shipping options and currency, etc.

On using Magentoโ€™s multi-store, you will be provided with the benefit that the data remain in a single location and segregated only when the user will be presented with the information.

This will provide you a total flexibility to target a specific segment of customers with marketing and promotion, beside simplifying store management and information.

Checkout Securely For Every Store.

If you have different stores dedicated to hosting environments, despite it is not advisable, still you can choose either parked or addon domain process as discussed above, and then edit httpd.confย file to provide IP address to these parked or add-on domains.

Most likely all these changes are overwritten with upgrade of control panel, PHP or Apache rebuild, and simple maintenance.

As a best-bet, you should purchase multiple or multi-domain certificate also named as UCC (Unified Communications Certificate). After setting up this SSL, you can simply go for parked domain process for your every assigned domain with UCC certificate.

Like this, your online business will surely get benefited by running in a flexible and secured environment. All of your stores will hold their own secure checkout, while still sharing the common back-end and code-base.

Now, navigate to your new store site and verify if the right Magento store is loaded?

If not the same, then make sure theย code MAGE_RUN_CODEmatch with the code created before. The domain should resolve to the right folder/path.

On browsing the URL, you should able to view each individual store.

While performing any of the above steps, if you are experiencing any issue, you can always get in touch with us and Hire Magento developer from India to avail our services at a very competitive price!

If you are willing to share any other process or idea to setup and manage domains and multiple stores in Magento with us, then please let us know about it on contact us.

Thanks for reading this blog!

Contact Us
Ellipsis-1s-200px