2

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?

  • Do you actually have multiple websites installed? Try var dumping $websites. – mbalparda Apr 10 '15 at 20:18
  • 3
    If each website has just one store, why not just use the store switcher? – Sander Mangel Apr 11 '15 at 10:38
  • 1
    I cannot see how the unmodified storeview switcher could be used to take a user to a different website only another storeview within the same website. – Calimo Apr 11 '15 at 15:25
  • Do you have any reason to not have all the store views under the same "website" - but with different URLs? I manage a 5 store-view Magento 1.9 install on 5 separate domains. We had our store switcher customized into tabs instead of the dropdown provided with Magento. If you don't need to separate your customers based on the store-view they are GEO-ip'd to, then this is your solution. – Steven J Jul 28 '17 at 16:16
0

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

Your Answer

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

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