3

On my current Magento project Wein-Partner.at I have to prepare multiple shops on one website.

For the different stores there will undoubtedly be different languages, also meaning multiple storeviews. However, the language selector disappeared on me and I have no clue where to. Interestingly enough I have a currency selector instead.

Is there a way for me to make a "store-selector" at the top, not just a store-view selector?

Do I have to enable the "add storecode to URL" for that?

The plan is basically as follows:

There's the website (wein-partner.at) which will open on the homepage, showing the main-store. Below that, if you click on a category, you come into category-view with additional tags to choose from (region, price, ..). If you click on, let's say a region that has only one winemaker, you're supposed to be taken to the winemaker's subshop showing his logo instead of ours (I currently can't change store, so it always shows the vendor's storeview).

The template-file is the same as the category-view aside from the logo (each vendor has his own storeviews as well [mainly probably English, German, French and Italian]).

To sum up, this means that there will be 4 levels (Website - mainstore - store/storegroup - storeview/store)

edit01: I found this so far (app/design/frontend/default/your_theme/template/page/switch)

<?php if(count($this->getGroups())>1): ?>
<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 ($this->getStores() as $_store): ?>
        <option value="<?php echo $_store->getUrl('') ?>"<?php if($_store->getId()==$this->getCurrentStoreId()): ?> selected="selected"<?php endif; ?>><?php echo $_store->getName() ?></option>
    <?php endforeach;*/ ?>
    <?php foreach ($this->getGroups() as $_group): ?>
        <?php $_selected = ($_group->getId()==$this->getCurrentGroupId()) ? ' selected="selected"' : '' ?>
        <option value="<?php echo $_group->getHomeUrl() ?>"<?php echo $_selected ?>><?php echo $this->escapeHtml($_group->getName()) ?></option>
    <?php endforeach; ?>
    </select>
</div>
<?php endif; ?>
  • If you have already created the other store views you can go into the admin System -> Configuration -> Design (tab) and set Package to 'base' and Theme to 'default'. This will show you the base Magento install. The Store Switcher will display in the footer. You can update layout XML to place this where you want it at on the page. – Jason Tipton Oct 28 '14 at 18:43
  • Ok in the default Magento design, the store switcher is visible in the footer like you said. That means in the custom design has to be either XML disabling it, or CSS making it invisible or moving it off the screen, right? edit: Firebug doesn't show any "switch" in the HTML, so it must have been removed per XML. – theHubi Oct 29 '14 at 12:26
5

The store switcher is loaded in the default theme via the layout (XML) file.

app/design/frontend/YOUR_PACKAGE/YOUR_THEME/layout/page.xml

Look for the following line of text:

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

If you copy that line of XML to the location you want it you can then add a call to display it in your template (phtml) file like such:

<?php echo $this->getChildHtml('store_switcher') ?>
  • <section id="header" class="header"> <?php echo $helper->getModulesByPosition('header') ?> <?php echo $this->getChildHtml('store_switcher') ?> </section> Like this? – theHubi Oct 30 '14 at 8:00
  • I've added the code in multiple sections, but can't seem to make it appear just yet. Am I missing some connection between the php and the XML? – theHubi Oct 30 '14 at 9:30
  • Sorry the XML snippet in my answer wasn't displaying. I have updated the answer. Be sure that you are copying the XML to the block where you want it loaded and also copying the php to the template location. – Jason Tipton Oct 30 '14 at 14:37
  • I noticed it was missing, but I know the XML code for the "page/switch" block. I've already copied the code to multiple locations before you edited your answer. I'm working on the fix though, as we speak. – theHubi Oct 31 '14 at 10:01
  • @JasonTipton How can i change header and footer for my multi store – zus Dec 26 '17 at 5:11
1

Locate page.xml in app/design/frontend/base/default/layout directory.

Open the file with a text editor and look for the code below.

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

To display the store switcher on the header of the page, we just have to change the location of the above code. This code is inserted in page/html_footerblock. Cut and paste it under the page/html_header block.

<block type="page/html_header" name="header" as="header">

Now to display the store switcher, go to header.phtml in the app/design/frontend/base/default/template/page/html directory and insert the following code.

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

make sure in your theme File stores.phtml is available if its not available get from this file from fresh magento from base template/page/switch/ folder

then make sure you put code correctly ! hope it should work fine !

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.