如何设置Magento 2网站切换器



我想为多个网站magento2商店设置网站功能与网站URL。也想从网站切换器选择当前网站Id下拉。

您可以使用以下命令。我只是在我的当前站点

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

谢谢

最新更新