php - 将字幕添加到类别列表 magento 2
问题描述
对于我的 magento2 商店,我希望在产品标题下方有一个副标题。
现在我用下一个代码为“产品概述”工作:
我将此代码添加到:catalog_product_view.xml
<referenceBlock name="category.product.addto">
<block class="" name="category.subtitle" template="product/view/subtitle.phtml" />
</referenceBlock>
我创建了一个新subtitle.phtml
的,其中包含下一个代码:
<h3><?php /* @escapeNotVerified */ echo $block->getProduct()->getResource()->getAttribute('subtitle1')->getFrontend()->getValue($block->getProduct()); ?></h3>
但我不知道如何让它在类别列表中工作。
有人可以帮助我吗?
更新:
我创建的属性具有正确的设置(在产品列表中使用已启用)
我正在使用的代码是:
<referenceBlock name="product-item-details"> <block class="Magento\Framework\View\Element\Template" name="category.subtitle" template="product/view/subtitle.phtml" /> </referenceBlock>
i placed this code in "catalog_product_view.xml
我没有在网格视图/类别视图中获得我的标题下方的字幕。
我认为参考块中的代码一定有问题,但我不知道问题出在哪里。
谢谢!关于马克
解决方案
推荐阅读
- c# - C#在许多看起来像列表的列表中选择一些列表
- python - 如何让我的数字猜谜游戏接受多个输入?
- python - Python -- 打开 xml 文件,根据 csv 中的数据更改数据,另存为新的 xml 文件
- javascript - 将 request.js 转换为 axios (Vonage api)
- python - 如何在 django 模板中迭代 dict 列表?
- python - 模型中数组的输入数据格式问题
- python - 如何将 else 语句添加到 dict 理解中?
- c++ - 程序在带有 3 个变量 C++ 的 while 循环中保持循环
- akka - akka java应用程序中aws s3的预签名URL
- node.js - 我想安装时出错( npm i --global @adonisjs/cli )