Our blog

 

Magento Multistore Setup in a Nutshell

One of the really cool features of Magento is the ability to easily setup a multistore on one installation of Magento. If you have never done it before though it can be a little tricky.

Here is very brief guide:

First create the stores. This is all done via the Magento administration.

System->Manage Stores

foreach store that you want, create a website, store and store view. Make a note of the codes as you need those in the code below.

Then in your index.php file have some code like this:

PHP:
  1. umask(0);
  2.  
  3.     switch($_SERVER['HTTP_HOST']) {
  4.  
  5.      case 'first-store.com':
  6.      case 'www.first-store.com':
  7.         Mage::run('store1', 'store');
  8.      break;
  9.  
  10.      case 'second-store.com':
  11.      case 'www.second-store.com':
  12.         Mage::run('store2', 'store');
  13.      break;
  14.  
  15.  
  16.      case 'third-store.com':
  17.      case 'www.third-store.com':
  18.         Mage::run('store3', 'store');
  19.      break;
  20.    
  21.      default: //run the default store if for some reason the above hasn't worked.
  22.         Mage::run();
  23.      break;
  24.       }

More Reading:

2 Comments

David
October 16th, 2009

Just to be clear, the two parameters for Mage::Run are 'websitecode','storecode' or 'storecode','websitecode' ? I got it to work by putting ONLY the storecode in, but not with both or with just the website code. This is a bit frustrating because I expect to have multiple language stores within one website (same domain), and I'm not quite sure how I can make that work. I'm using Magento 1.3.4 currently. Any other hints that you might add in this topic would be great!

 

admin
December 4th, 2009

the second parameter is either 'website' or 'store' and defines what type of code the first parameter is

 

 

Leave a Reply