we have multi store views site.

we provide an option to change store views through dropdown here as below :

enter image description here

once we change option from dropdown, it will display selected store view.

but once we click on any other page[ menu, catalog, Product ,cms ] it will again display old store view.

but it should be in same store view until we change it manually.

Is i need to use cookies for saving ?


class Atwix_Ipstoreswitcher_Model_Observer
     * redirects customer to store view based on GeoIP
     * @param $event
     public function controllerActionPostdispatch($event)

       $geoIP = Mage::getSingleton('geoip/country');
        $cnCode =  $geoIP->getCountry();
       // echo $cnCode;
       // echo $cnCode='IN';
            switch ($cnCode) {
                case "US": {
                case "IN": {
                case "CA": {
                case "UK": {

                case "AU": {




<?php if(count($this->getStores())>1): ?>
$lis = "";
$selCurrency = $this->__('Currency');
foreach ($this->getStores() as $_lang):
    if($_lang->getId() == $this->getCurrentStoreId()){
        //This line will show SYMBOL only
        //$selCurrency = "[".Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol()."]";

        //This line will show FULLNAME
        $selCurrency = '  '.$this->escapeHtml($_lang->getName());
    $lis .= '<li><a href="'.$_lang->getCurrentUrl().'">'.$this->escapeHtml($_lang->getName()).'</a></li>';
<div class="form-language">
    <ul id="select-language" title="<?php echo $this->__('Currency') ?>" class="dropDownMenu">
        <li><a href=""><?php echo $selCurrency ?></a>
            <?php echo $lis ?>
<?php endif; ?>

1 Answer 1


First of all, looks like your observer.php sets the store always to "India", is that correct?

About your question, the best option is to have a separate URL for each store view, which could be a subdirectory (example.com/store2), subdomain (store2.example.com) or even a new domain (example2.com).

This link explains more about this topic.

After choosing your approach, you need to:

  1. Create the Store View in Magento admin panel
  2. Create the new address (subdomain, subdirectory or new domain) in you server and copy the files index.php and .htaccess to that new folder.
  3. Edit the bottom of index.php in the line: Mage::run($mageRunCode, $mageRunType); to set your RunCode (code of the store defined in Magento admin) and RunType (store or website).

  4. Go to System > Configuration > General > Web and make sure that you are editing the right Store View (you can change it in the upper left corner under "Current Configuration Scope").

  5. Under the tabs Unsecure and Secure, change the Base URL field to match your new store view URL.

After that, you need to create symlinks for the Magento files, this will allow you to keep navigating in the same store view.

Use SSH to access the root folder of your new storeview /home/example/example.com/html/store2/ and execute this:

ln -s /home/example/example.com/html/app/ app
ln -s /home/example/example.com/html/includes/ includes 
ln -s /home/example/example.com/html/js/ js 
ln -s /home/example/example.com/html/lib/ lib 
ln -s /home/example/example.com/html/media/ media 
ln -s /home/example/example.com/html/skin/ skin 
ln -s /home/example/example.com/html/var/ var

This should solve your problem.

If you want to read more: https://docs.nexcess.net/article/how-to-configure-multiple-magento-storefronts.html

  • Thanks for nice information, but client don't want url in that way. Jun 9, 2016 at 5:35
  • Oh ok...I am sorry, but I am not sure how to do that without changing URLs. I had the same problem with a client and I explained the importance of having different URLs (even as a subdirectory) as stated in this article. Jun 9, 2016 at 17:27
  • 1
    If I find any other helpful information I will post here. Good luck with your project and, again, if possible I would suggest talk with your client to change the approach, since is better for SEO and also user experience; although I know that sometimes is hard to change the client's mind :) Jun 9, 2016 at 17:30
  • you are absolutey right regarding url structure that helps for seo & clients mind :-) Jun 9, 2016 at 20:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.