0

I have a magento multistore website, I need to list all the store and create a link to their home page, for do it I create this template:

  <?php $stores = Mage::app()->getWebsite()->getStores();?>
  <?php foreach ($stores as $_store): ?>

    <div class="store">
    <div class="title">
      <?php echo $this->htmlEscape($_store->getName()) ?>
    </div>
    <div class="description">
      <p><?php echo Mage::getStoreConfig('design/head/default_description',$_store->getStoreId()); ?></p>
      <a href="#" class="link-sito">Vai al sito</a>
      <a class="link-to-store" href="<?php echo $this->htmlEscape($_store->getHomeUrl())?>">Vai al Negozio</a>
    </div> 
  </div>
  <?php endforeach; ?>

the code works until I have 2 store view, intact the code display all 2 view instead only one, there is a way to display only the store and link to correct home page based on current language?

Vickel
  • 7,879
  • 6
  • 35
  • 56
francesco.venica
  • 1,703
  • 2
  • 19
  • 54

1 Answers1

0

Take a look @ Getting a list of magento stores

foreach (Mage::app()->getWebsites() as $website) {
    foreach ($website->getGroups() as $group) {
        $stores = $group->getStores();
        foreach ($stores as $_store) {
            <div class="store">
               <div class="title">
                  <?php echo $this->htmlEscape($_store->getName()) ?>
              </div>
                ...
            </div>
        }
    }
}
Community
  • 1
  • 1
MagePal Extensions
  • 17,646
  • 2
  • 47
  • 62