2010-11-24 44 views

回答

9

發現了Magento的論壇解決方案:http://www.magentocommerce.com/boards/viewthread/8296/

您的自定義主題包來創建app/design/frontend/base/default/template/page/switch/stores.phtml模板的副本。

然後,你必須修改它使用下面的代碼:

<?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; ?> 

鏈接的方法Magento的API文檔中使用: