Magento – How to add a website switcher instead of store view switcher

ce-1.9.1.0magento-1.9multistorewebsites

I have 3 websites (mydomain.com/us/, mydomain.com/en/ and mydomain.com/eu/), each has one store view. I want to switch between these 3 Magento websites with a dropdown switcher similar to that used for switching store views, but there isn't one for switching websites. There are dropdowns for switching language, currency and storeviews but not for switching websites.

I know this has been asked previously and I have tried to apply those solutions.

I found a previous solution to this at;
https://stackoverflow.com/questions/4270490/how-do-i-get-a-website-switcher-instead-of-store-switcher

Following these instructions, I copied;

app/design/frontend/base/default/template/page/switch/stores.phtml

to;

app/design/frontend/{my_theme_package}/{my_theme}/page/switch/stores.phtml

and replaced existing with following code;

<?php
$websites = Mage::app()->getWebsites();

if (count($websites) > 1): ?>
<div class="website-switcher">
    <label for="select-website"><?php echo $this->__('Select Store:') ?></label>
    <select id="select-website" title="<?php echo $this->__('Select Store') ?>" onchange="location.href=this.value">
    <?php foreach ($websites as $website): // print out each website name and code as a dropdown box item ?>
        <?php $_selected = $website->getCode() == Mage::app()->getWebsite()->getCode() ? ' selected="selected"' : '' ?>
        <option value="<?php echo $website->getDefaultStore()->getBaseUrl()?>"<?php echo $_selected ?>><?php echo $this->htmlEscape($website->getName()) ?></option>
    <?php endforeach; ?>
    </select>
</div>
<?php endif; ?>

I then refresh cache and when I check the site, there is no switcher where I expect it to be?

Currently each website has one storeview but I may want to add additional storeviews to the EU site for different language versions at some future point.
I have already tested this by adding an additional storeview to the EU website and when I go to mydomain.com/eu/ the storeview switcher does appear for these eu-en and eu-de storeviews.
Additionally, for testing purposes I have also added an additional storeview to US website, the storeview switcher does appear for us or canada storeviews.
When I go to either the mydomain.com/ or mydomain.com/uk/ websites there is no storeview switcher which is correct.
Looking at it now I probably need a website switcher and possibly a storeview switcher together in the scenario of having more than one EU storeview, other than Geo-IP Default Store, is there an extension for this?

Best Answer

You stated you copied it over to

app/design/frontend/{my_theme_package}/{my_theme}/page/switch/stores.phtml

which lacks the template folder

The correct path would have been

app/design/frontend/{my_theme_package}/{my_theme}/template/page/switch/stores.phtml

Related Topic