ストアだけでなく、ウェブサイトを切り替えるためのドロップダウン メニューを作成するにはどうすればよいですか?
具体的には、Magento の Web サイトを切り替えたいと考えています。テンプレートには、ストアを切り替えるためのドロップダウン メニューと言語を切り替えるためのドロップダウン メニューがありますが、Web サイトを切り替えるためのドロップダウン メニューはありません。
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 ドキュメントへのリンク: