【问题标题】:How to setup Magento 2 website Switcher?如何设置 Magento 2 网站切换器?
【发布时间】:2016-09-02 10:22:02
【问题描述】:

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

【问题讨论】:

    标签: magento2


    【解决方案1】:

    您可以通过以下方式做到这一点.. 我只是在我当前的网站上这样做

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

    谢谢

    【讨论】:

    • 如何切换商店而不是网站。还请告诉我把这段代码放在哪里,我是 Magento 的新手。谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-25
    • 2012-02-03
    • 1970-01-01
    • 1970-01-01
    • 2017-12-19
    • 2011-08-05
    相关资源
    最近更新 更多