我在自定义主题中实现了自定义商店切换器。
块模板如下:
<?php if (count($block->getStores())>1): ?>
<?php $id = $block->getIdModifier() ? '-' . $block->getIdModifier() : ''?>
<span><?php echo $block->escapeHtml($block->getStoreName()) ?></span>
<span>/</span>
<?php foreach ($block->getStores() as $_lang): ?>
<?php if ($_lang->getId() != $block->getCurrentStoreId()): ?>
<span class="view-<?php echo $block->escapeHtml($_lang->getCode()); ?> switcher-option">
<a href="#" data-post='<?php /* @escapeNotVerified */ echo $block->getTargetStorePostData($_lang); ?>'>
<?php echo $block->escapeHtml($_lang->getName()) ?>
</a>
</span>
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>
正确显示了到新商店的链接,因此我认为xml内容还可以,但是单击时会收到以下错误:
section-config.js:33未捕获的TypeError:无法读取未定义(...)的属性'*'
生成html
的内容如下所示:
<span class="view-it switcher-option">
<a href="#" data-post="{"action":"http:\/\/test.mysite.eu\/stores\/store\/switch\/","data":{"___store":"it","uenc":"aHR0cDovL3Rlc3QuZnJhZ2lhY29tb21pbGFuby5ldS8,"}}">
It
</a>
</span>
sudo php bin/magento setup:static-content:deploy
没有运气。为什么要删除var
文件夹?我到底应该删除什么?