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

时间:2018-06-19 07:55:41

标签: twig opencart-3

我在opencart 3中创建了一个名为'Flavor'的属性,并希望在每个产品的类别布局(category.twig)中显示此属性,其中标题,价格,添加到购物车等。

由于

1 个答案:

答案 0 :(得分:0)

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

'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 %}  

请注意,您必须将属性循环上的14替换为确切的属性ID。您可以从“属性”部分的管理面板中进行检查。

希望这可以解决您的问题。

相关问题