How to set multiple websites with multiple store views in Magento

Featured Image

If you work with Magento, sooner or later you will end up needing multiple websites that have
multiple languages.
Most of you know this, but I hope someone will still find this post useful.

There are few ways of doing same thing, but in my experience way I’m going to present now causes
less problems even though it is less automatic than some other ways.

Let’s say we want 2 websites and 2 languages for each site.

Here’s procedure:

In admin panel, go to System->Configuration and click on “Manage Stores”
Click on “Main Website” to change it’s name to “Website 1″ or however you want to call it. (I’ll call mine “Website 1″ for the purposes of this article).
In “code” field there, write something like “website_1″.

Do same for “Main Website Store”. Call it “Website store 1″.

And guess what… do same for “Default Store View” that you can find on same interface.
How to call it?
Hm… I’ll call mine “English Store View”
I’ll write “english_store_view_website_1″ in “code” field there.

Ok, let’s go make second one…
Add website named “Website 2″ with code “website_2″.
Add store called “Website store 2″ and assign it to Website 2 that you can chose from dropdown.
Add new store view called “English Store View” with code “english_store_view_website_2″ and
assign it to “Website 2″ that you can find in dropdown.

By now you should have 2 websites with 1 language each.

Add two more store views.
Call first “German Store View” with code “german_store_view_website_1″.
Call second “German Store View” with code “german_store_view_website_2″.
Assign them to corresponding websites.

Let’s see what we have at this moment:

1) a) Website 1 (code: website_1) – Website Store 1 English Store View (code: english_store_view_website_1)
b) Website 1 (code: website_1) – Website Store 1German Store View (code: german_store_view_website_1)

2) a) Website 2 (code: website_2) – Website Store 2 English Store View (code: english_store_view_website_2)
b) Website 2 (code: website_2) – Website Store 2German Store View (code: german_store_view_website_2)

Of course, I didn’t mentioned that you will need to chose root category for your stores, do what ever you like there.

Ok, let’s say we want url to be handled this way:
1) http://www.yourdomain.com/website_1
2) http://www.yourdomain.com/website_2

In your Magento installation directory, make 2 directories called “website_1″ and “website_2″
Copy .htacces and index.php from your root directory in each of those new directories.

In .htaccess search for “RewriteBase /” line and replace it with “RewriteBase /website_1/” in first directory, and
search for “RewriteBase /” line and replace it with “RewriteBase /website_2/” in second directory.

In both directories open index.php and change “$compilerConfig = ‘includes/config.php’;” to
$compilerConfig = ‘../includes/config.php’;

Change $mageFilename = ‘app/Mage.php’; to $mageFilename = ‘../app/Mage.php’;

In same file make sure to edit Mage::run() function for each site:

Mage::run(‘website_1′, ‘website’);
Mage::run(‘website_2′, ‘website’);

Go to System->Configuration and select Current Configuration Scope: Website 1

Set absolute paths to your skin, js and  media directories and set Base URL = http://www.yourdomain.com/website_1  (do that for website_2 too)

Now use this dirty way to switch between websites :)
http://inchoo.net/ecommerce/magento-snippet-for-switching-between-websites/

Since there is much to say about this subject, feel free to ask questions and I’ll try to answer them asap.

92
Top

Care to rate this post?

Author

Tomas Novoselic

Team Leader, Backend Developer

At Inchoo, Tomas is a Team Leader and Certified Magento Developer who handles Magento modifications at any level. He also works closely with clients on Magento projects of any size and difficulty.

Other posts from this author

Discussion 92 Comments

1 2
Add Comment
  1. One last thing only, how can i translate below code its heading of deal you can check here
    http://bonaty.com/?___store=arabic&___from_store=default

    <?php echo $this->htmlEscape($_product->getName()) ?>
  2. also city are not translate able please help me , thanks

    <?php echo $final[Mage::getSingleton('core/session')->getCity()]; ?>
  3. To translate product name, you need to open that product in admin, in the “Choose Store View” selector choose your Arabic Store View, now type in product name in Arabic into the product name field.

    As for the city name, just pass it through translator function like this $this->__($final[...]) and specify Arabic names for possible city values in one of .csv files under app/locale/language.

  4. @jawad Trying to copy other people’s design is not very nice. I’m talking about this:
    http://bonaty.com/?___store=arabic&___from_store=default

    Just a friendly advice: If you are having trouble at this point (setting those websites) maybe you should consider to give up. Gonabit is not something you download from magento connect. Thank you.
    P.S. You are literary commenting post on the blog of the people that actually made site you are trying to rip off check this: http://inchoo.net/category/portfolio/

  5. TOmas, you are right, its demo store and we change the design then we launch finally
    thanks

  6. @jawad Well, about that… Ok, if you say so…
    However, I find it less likely that somebody would really spent that much time just so he could “change it” once you go live… You even have logo almost identical…well good job…:P

  7. Thanks sir, i promise to you i will change though its my client requirments but i will force him to change the things, also am sure you understand that in development mode developer use the dummy things for saving the time , thank you so much for help

  8. also i know you already have built the gonabbit and you are the full understanding the system but your team not help me to manage the things but on this forum vistors help me a lot, please apology me if i think wrong and delete this comments
    thanks

  9. Tomas

    @jawad – You can’t seriously think I’ll help you to steal from our client? LOL. And yea…this is not forum and this is not support group. Especially not for you!

  10. @Tomas LOL, thanks for taking very positive

  11. Fida

    Hello

    I have one main website with one store and 2 store views.

    I have added the products to the store and hope it will be visible in 2 views.

    But here only English page have the products displayed and no products are displayed on German Page.

    I would like to have the products and English Page to be in the German Page too with translation in the name and description

    Please let me whether it possible in Magento.

    Looking forward for your replies as soon as possible as i am stuck upon my project

  12. Clear cache or even better disable it for the setup period (Admin>System>Cache Management), run full reindex (Admin>System>Index Management).

  13. Fida

    @Konstantin i ahve done it but no chnage. but ifi edit a product in german language it will appear. So what i need to do if i need one product to appear in both views.

  14. The problem you have is not exactly what this post is about. It’s more about the technical side of setting up multi-website in Magento. As far as I know all Store Views under one Store/Website should display all of your products without any special actions. Editing product in a particular store view just gives you the ability to override the default values with their translations or disable certain products in a particular Store View. So it seems unusual that your products are not visible in other Store Views under the same Store/Website if you haven’t explicitly disabled them.

    As a check-list you may do the following:
    - make sure you are talking about Store Views, not different Websites
    - pick a product that is not visible on German Store View, go into that product in Admin, switch Configuration Scope to German Store View and see if it has Status=Enabled and Visibility=Catalog, Search

    No other setting affect products display on other Store Views within same Store/Website.

  15. Philippe

    This is wizardry! Thank you very much for this helpful article!

  16. Albercar

    Dear Tomas, my respect. This multiwebsite topic maybe somehow confusing. Here’s my case: I got a local installation in D:\xampp\htdocs\magento (Windows) which I access from http://www.magentolocal.com (virtual host => DocumentRoot “/xampp/htdocs/magento”). No problem so far. I left Main Website as is and added a new website. I placed the folder “new_website” (htaccess and index) under D:\xampp\htdocs (the same level as “magento” folder); then I copied “../app/design/frontend/base” folder and renamed it as “base_new_website”… that is, set the interface/theme pair for the new website… finally, I set BaseURL to “http://www.magentolocal.com/new_website/”, went to the browser, typed this url and got the magento’s “404 error” webpage. What advise would you give to this dummy beginner? Thanks in advance.

  17. If you are running the latest version of Magento you can not bother with creating a new directory and just tick Add Store Code to Urls in system > web > url options!!! Took my hours to find the right blog with this info in.

  18. Ami

    it’s great and help lot.thank.Please give me any solution for one cart and one checkout for multiple websites with multiple store views in Magento.

  19. it’s great and help lot.thank.Please give me any solution for one cart and one checkout for multiple websites with multiple store views in Magento.

  20. Adrian Smith

    Hey, Great post, thanks a lot! Just a quick question, which bit would be my magento installation directory – just the main folder? Also, will this method work if i want the store fronts to look exactly the same?

    Thanks :)

    In your Magento installation directory, make 2 directories called “website_1? and “website_2?
    Copy .htacces and index.php from your root directory in each of those new directories.

  21. I make the described steps but my second website is showing without styles…. some sugestion?

    Thanks!

  22. doug

    This is almost exactly what I had to do, thanks! (two websites, each with one store/storeview each – Retail/Wholesale).

    Have you tried importing images? I’m having issue with image settings. For a product, image for Retail is set properly, but for Wholesale and Default Values, image radio buttons are set to No Image. And even though Retail has radio buttons for images selected, image won’t show up on frontend until I set Default Values image (it won’t build out cache under media/catalog/products/ until I set Default Values).

    I know this is only tagentilly related to your post (mutli-site/multi-store), but if there’s something obvious I’m missing, it would be awesome (I know it has to do with catalog_product_entity_media_gallery – I’ve found a way to update Wholesale via SQL, but not Default Values)

  23. Sander

    Hi Thomas, thanks for this blog. Looks simple :-) But not working for me. Hope you can help me.

    I have this setup

    Main Website – Main store – Language 1 (code: nl)
    Main Website – Main store – Language 2 (code: fr)

    I want the first to just be the root. So no changes there.
    For the fr one I have added a folder, changed index.php, changed the .htaccess and the urls.

    I always get a 404 page with the toplinks but nothing else. I think he cannot load the cms pages or something. Do you know what is wrong?

  24. I’ve successfully managed to get multistore working (second domain name is loading second magento store) but no css/design is loading – what is the best (correct) process to get the second store to load it’s theme (I thought just inserting the name of the theme in the admin -> system -> configuration -> design for the second store would do it but it doesn’t seem to be grabbing the design at all. Thanks

  25. sanjay

    Hi,
    I have followed all the step to create the store and it does.
    When I enter the store path ie.
    http://magentodemo.localhost/website_1/
    it show the home page without CSS. ie page with
    just Store information without any images and template.
    Could you plz tell me what goes wrong while creating
    store.
    Thanks in Advance.

  26. Case: 1 magento installation, 5 stores each with 6 store views. By default magento creates seperate increments and prefixes for each and every store view. I want to realize increments and prefixes per store. All store views per store have to share their increments and pre fixes. – I’ve been looking for ages, hope someone here can help me in the right direction.

    Thanks in advance

  27. Arth

    Thank you very much. Helped me a lot :)

  28. is it same for magento 1.7 ? not working inmy case as m using magento 1.7
    ?

  29. I use 4 stores build on 1 system. Not all products are shown on each store. I have problem with breadcrumbs, they are showing wrong, and linking to another store? any solution?

  30. What if I need to have different Domain for Different Store view?

  31. shahnawaz jafer

    hi all;
    i have a problem in magento site. i have website with
    five store view i want assign individual product to individual store view .
    could any help me plz..

  32. Purvi123

    i wnat to put drop down for price field in advanced search

  33. Magentouser

    I am following the same steps…I have created two different stores…But the first problem i am getting is I cannot access to two different stores at the same time..means..I have to set one store as default…the other will not work…..

  34. Davide

    I have follow this guide but not work, i have this problem :
    Parse error: syntax error, unexpected ‘{‘ in /data/web/e29834/html/website_2/index.php on line 47

  35. Neha p

    Hi,

    I am getting an error

    app\Mage.php was not found

    plz help me

  36. @Neha, i assume you are using 1.7.0.2. After copying the index.php from root to your website folder wont work. You need to tweak the lines on 47 & 52

    Change it from

    $compilerConfig = MAGENTO_ROOT . '/includes/config.php';

    to

    $compilerConfig =  '../includes/config.php';

    and

    $mageFilename = MAGENTO_ROOT . '/app/Mage.php';

    to

    $mageFilename = '../app/Mage.php';

    This should fetch the file now.

    However, i still have a problem that i can see my 2nd website with the right category, but clicking on the category, it takes the link of default website like http://www.test.com/paintings.html instead of http://www.test.com/website_2/paintings.html

    It is missing the website_2 in the link.

    Any takers to help on this?

  37. Thank you for this – very informative. When I select Add to Cart on a product, it reverts back to the other country (ie. I have a site for Canada, and one for the US. When I select the US site from the drop down, and click Add to Cart, it defaults to the Canada Shopping Cart.)

    Must be a configuration missed somewhere – any ideas?

    I’m running Magento ver. 1.7.0.2 (and yes, my base URL is http://www.thingsthegame.com/orders/ for both and the base link is http://www.thingsthegame.com/orders/canada for Canada Site and http://www.thingsthegame.com/orders/us for US Site

    Any help or suggestions would be great!!! Thanks in advance :D

  38. Omar

    i am getting Internal Server Error when i go to any links both websites home page loading successfully any help please

  39. Kulvinder

    sir i have tried this “http://www.geekieblog.com/2011/10/adding-a-new-language-to-magento/

    ” ,, it shows option in dropdown but does not translate the store into that particular language,, can any body resolve it where i am making mistak,, thanks alot…

  40. Dirk

    Hi Tomas,
    Great tutorial! english_store_view_website_1 has English as default that I can re-use in english_store_view_website_2.
    But how can I re-use the data of german_store_view_website_1 without having to copy al the data to german_store_view_website_2?

  41. Hi,

    I need a solution similar like that but the problem is I have a lots of categories in every store, now if I make 2 store views for every store then it’ll be a huge category setup. Now according to above example, I have to manage all categories for every store view. How can I overcome with this situation. Please help!!!

1 2

Add Your Comment

Please wrap all source codes with [code][/code] tags.
Top