Question

I have a website in Magento 1.9 called www.example.com. In Magento, we know that we can create multiple websites so I have created like that multiple websites with their own store and store view. so I have the site.

example.com(default)
example.com(2)
example.com(3)
example.com(4)

My requirement is I need to switch to these websites by staying the same URL (www.example.com). Can any one help me to do this?

Was it helpful?

Solution

After some experiments i have found the solution.You can pass the website code in get parameter and on the basis of that code run the website in index.php. This way your url will not be changed and also set a session for website code.

if (isset($_GET["website"])){
   $web=$_GET['website'];
}

if($web=="clt")
{
   $mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? 
   $_SERVER['MAGE_RUN_CODE'] : 'clt';
   $mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'website';
   Mage::run('clt', 'website');
}
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top