1

I took over this webshop. They made a store switcher themselves. You can see the select list in action in the header. I want to add the default store switcher from /app/design/frontend/default/trendy-green/template/page/switch/stores.phtml.

  • Its listed in /app/design/frontend/default/trendy-green/layout/page.xml like:

        <block type="page/html_wrapper" name="bottom.container" as="bottomContainer" translate="label">
            <label>Page Footer</label>
            <action method="setElementClass"><value>bottom-container</value></action>
        </block>
        <block type="page/switch" name="store_switcher" as="store_switcher" template="page/switch/stores.phtml"/>
        <block type="page/template_links" name="footer_links" as="footer_links" template="page/template/links.phtml"/>
    </block>
    
  • I already tried to load the default theme but no result...

Why the default store switcher isn't showing up?

2 Answers 2

0

"Store" switcher that appear in default theme is actually built for switching Store Views (Languages)

it's included in layout as

<block type="page/switch" name="store_language" as="store_language" template="page/switch/languages.phtml"/>

and in header.phtml as

<?php echo $this->getChildHtml('store_language') ?>

To make it visible - make sure that you have several Store Views in your current store and all of them are Enabled.

And to make Store Switcher available, insert next line in page.xml of your theme

  <block type="page/switch" name="store_switcher" as="store_switcher" template="page/switch/stores.phtml"/>

near store_language block and use

<?php echo $this->getChildHtml('store_language') ?>

in header.phtml

7
  • No i don't need store_language. I only need store_switcher. To switch between the different stores and continue shopping in the card. In header or footer (I tested both) I have <?php echo $this->getChildHtml('store_switcher'); ?>
    – meez
    Commented Apr 11, 2016 at 20:18
  • and can you provide part of layout/page.xml (as it's invisible in your first post) ? + did you checked if several stores are enabled and linked to one website?
    – Neklo.com
    Commented Apr 11, 2016 at 20:21
  • I update my question. Yes now in header there is the other store switcher. You can switch between stores with this select list.
    – meez
    Commented Apr 11, 2016 at 20:29
  • ok. in my store Store switched didn't appeared by default too. But you can try to comment first and last lines in stores.phtml - <?php // if(count($this->getGroups())>1): ?> <?php //endif; ?> and maybe it will help
    – Neklo.com
    Commented Apr 11, 2016 at 20:38
  • + please check if each store on your website have active Store View
    – Neklo.com
    Commented Apr 11, 2016 at 20:38
0

I think you can just replace code of store_switcher.phtml with next

<?php
/**
 * Store switcher template
 *
 * @see Mage_Core_Block_Store_Switcher
 */
?>
<div class="store-switcher">
    <label for="select-store"><?php echo $this->__('Select Store:') ?></label>
    <select id="select-store" title="<?php echo $this->__('Select Store') ?>" onchange="location.href=this.value">
    <?php foreach (Mage::app()->getStores() as $store): ?>
        <?php $_selected = ($store->getStoreId()==$this->getCurrentGroupId()) ? ' selected="selected"' : '' ?>
        <option value="<?php echo $store->getBaseUrl() ?>"<?php echo $_selected ?>><?php echo $this->htmlEscape($store->getName()) ?> <?php echo $store->getBaseUrl() ?></option>
    <?php endforeach; ?>
    </select>
</div>

and then you'll have all stores in switcher

1
  • Thanks. Then all stores are visible so that works, but I can't continue shopping in the other shops and add products and go to checkout (merge shopping card). Is this possible with the default store switcher?
    – meez
    Commented Apr 18, 2016 at 12:23

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.