Magento – Multiple country-specific stores on the same domain: Show country selection first

ce-1.7.0.2magento-1.7multistore

I am currently working on a shop that serves two countries: UK and Germany. The shop has the same inventory and content for both countries, only the proudct prices are different.

I have learned that I have to create two different Websites in Magento in order to be able to show different prices for the same product. I have done that and now I have a different URL for each country: example.com/uk and example.com/de.

Now when a customer goes to example.com, they should be presented with a country selection, e.g. "Please select your country: UK or Germany".

What is the suggested solution here? I have tried creating a third "Country Selection" website that is the default website and that has this "Country Selection" CMS page as its CMS Home Page, but that feels really hacky and also the content is then also available at example.com/some-product…

Best Answer

Assuming you have 1 domain: domain.com with a running Magento installation with 2 websites (with each 1 store) I would suggest the solution below.

Create 2 sub-directories in your Magento root folder like this:

<magento-root-folder>
  en
    symlink to ../app
    symlink to ../errors
    symlink to ../.htaccess
    symlink to ../js
    symlink to ../lib
    symlink to ../media
    symlink to ../skin
    copy of ../index.php with some modifications
  de
    symlink to ../app
    symlink to ../errors
    symlink to ../.htaccess
    symlink to ../js
    symlink to ../lib
    symlink to ../media
    symlink to ../skin
    copy of index.php with some modifications

After that I would adjust the base urls of both websites to be:

domain.com/en
domain.com/de

Make the requirement modifications of index.php in each sub-directory:

Replace

/* Store or website code */
$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';

/* Run store or run website */
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';

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

with (*don't forget to modify 'THE_CORRECT_STORE_CODE' in the below code snippet*)

Mage::run('THE_CORRECT_STORE_CODE', 'store');

Inside your Magento-root folder I would create a index.html file that will server as the language selection page. (When doing this don't forget to change the DirectoryIndex index.php inside the .htaccess file)

Also in this .htaccess file you should redirect all traffic that wants to visit non language/country specific urls to the language selection page...

I hope this helps you out ;)

Related Topic