gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 20:14:56 25 4
gpt4 key购买 nike

我想使用网站 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com