Twig 在类别页面上显示产品属性-Opencart 3

Twig 在类别页面上显示产品属性-Opencart 3,twig,opencart-3,Twig,Opencart 3,我在opencart 3中创建了一个名为“风味”的属性,并希望在每个产品的类别布局(category.twig)中显示该属性,其中包含标题、价格、添加到购物车等 谢谢在产品结果循环内的类别控制器中添加以下代码 'attribute_groups' => $this->model_catalog_installer->getProductAttributes($result['product_id']), 然后在category.twig页面上添加以下代码以查看特定属性 {%

我在opencart 3中创建了一个名为“风味”的属性,并希望在每个产品的类别布局(category.twig)中显示该属性,其中包含标题、价格、添加到购物车等


谢谢

在产品结果循环内的类别控制器中添加以下代码

'attribute_groups' => $this->model_catalog_installer->getProductAttributes($result['product_id']),
然后在category.twig页面上添加以下代码以查看特定属性

{% if product.attribute_groups %}
    {% for attribute_group in product.attribute_groups %}
      {% for attribute in attribute_group.attribute %}
         {% if attribute.attribute_id == 14 %}
              <p>Flavour: <span>{{ attribute.text }}</span></p>
         {% endif %}
      {% endfor %}
    {% endfor %}
{% endif %}  
{%if product.attribute\u groups%}
{product.attribute_groups%}
{属性_group.attribute%}中的属性为%
{%if attribute.attribute_id==14%}
味道:{{attribute.text}}

{%endif%} {%endfor%} {%endfor%} {%endif%}
请注意,您必须用准确的属性id替换属性循环中的14。您可以从属性部分的管理面板中进行检查


希望这能解决你的问题

有没有可以共享的源代码?你能不能也请你的问题,也许提供一个样本图像?谢谢