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

标签 magento2

我想使用网站 URL 为多个网站 magento2 商店设置网站功能。还想从网站切换器下拉列表中选择当前网站 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>

谢谢

关于magento2 - 如何设置 Magento 2 网站切换器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39290073/

相关文章:

Docker - Xdebug 调试 PHP CLI 脚本(VS 代码)

php - 无法删除标题 "vary: user agent"

magento2 - Magento 2.1.1 无效的 block 类型异常 - 找不到类

Magento 2 在设置 :static-content:deploy and frontend page broken 时减少编译错误

Magento2动态按摩

magento2 - Magento 2.2.4 代不存在

php - Magento 2 - ajax 更改数量后重新加载总计购物车

magento2 - Magento 2 - 将页脚新闻通讯注册添加到 CMS 中的内容 block

rest - Magento2 REST API。属性到属性组

magento2 - 在 Magento 2 上的 sales_order 表中编辑 increment_id 的长度