如何设置Magento 2网站切换器?

时间:2016-09-02 10:22:02

标签: magento2

我想使用网站网址为多个网站magento2商店设置网站功能。还想从网站切换器中选择当前网站ID下拉。

1 个答案:

答案 0 :(得分:2)

您可以通过以下方式执行此操作..我只是将其添加到我当前的网站

<div class="switcher store switcher-store" id="switcher-store">
<strong class="label switcher-label"><span><?php echo __('Select Store') ?></span></strong>
<div class="actions dropdown options switcher-options">
    <?php foreach ($websites as $website): ?>
    <?php if ($websiteid == $website->getId()): ?>
        <div class="action toggle switcher-trigger"
             role="button"
             tabindex="0"
             data-mage-init='{"dropdown":{}}'
             data-toggle="dropdown"
             data-trigger-keypress-button="true"
             id="switcher-store-trigger">
            <strong>
                <span><?php echo $block->escapeHtml($website->getName()) ?></span>
            </strong>
        </div>
    <?php endif; ?>
    <?php endforeach; ?>
    <ul class="dropdown switcher-dropdown" data-target="dropdown">
        <?php foreach ($websites as $website): ?>
        <?php if (!($websiteid == $website->getId())): ?>
            <li class="switcher-option">
                <a href='<?php echo $website->getDefaultStore()->getCurrentUrl() ?>'>
                    <?php echo $block->escapeHtml($website->getName()) ?>
                </a>
            </li>
        <?php endif; ?>
        <?php endforeach; ?>
    </ul>
</div>

谢谢