2010-11-24 8 views
4

店舗だけでなくウェブサイトを切り替えるためのドロップダウンメニューを作成するにはどうすればよいですか?ストアスイッチャーの代わりにウェブサイトスイッチャーを取得するにはどうすればよいですか?

具体的には、Magentoのウェブサイトを切り替える必要があります。店舗を切り替えるためのテンプレートと言語を切り替えるためのドロップダウンメニューがありますが、ウェブサイトを切り替えるためのメニューはありません。

答えて

9

は、Magentoのフォーラムで解決策を見つけた:http://www.magentocommerce.com/boards/viewthread/8296/

あなたのカスタムテーマパッケージにapp/design/frontend/base/default/template/page/switch/stores.phtmlテンプレートのコピーを作成する必要があります。使用方法のためのMagentoのAPIドキュメントへ

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

リンク::

関連する問題