4
如何創建切換網站的下拉菜單,而不僅僅是商店?如何獲得網站切換器而不是存儲切換器?
更具體地說,我想在Magento網站之間切換。模板中有一個用於切換商店的下拉菜單,另一個用於切換語言,但切換網站時沒有。
如何創建切換網站的下拉菜單,而不僅僅是商店?如何獲得網站切換器而不是存儲切換器?
更具體地說,我想在Magento網站之間切換。模板中有一個用於切換商店的下拉菜單,另一個用於切換語言,但切換網站時沒有。
發現了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文檔中使用: