0

I have a website with multiple websites and multiple store views. To display store switcher in the header I have added the below code.

<ul class="sub-lang">
    <?php foreach ($helper->getWebsites() as $website) {
              foreach ($website->getGroups() as $group) {
                            $stores = $group->getStores();
                            foreach ($stores as $store) { ?>
                                <li><a class="<?php echo $store->getName(); ?>" href="<?php echo $helper->getCurrentUrl(); ?>"><?php echo $store->getName(); ?></a></li>
                        <?php   }
              }
    } ?>
</ul>

But I'm getting incorrect URLs. for example, I'm on the page http://www.example.com/test-product.html

For example, for the store CA, I'm getting http://www.example.ca/catalog/search/index/...

It should return the correct URL according to the current page URL. http://www.example.ca/test-product.html?___store=ca&___from_store=default

Also I have noticed that it's showing last visited page url in $helper->getCurrentUrl();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.