在类别页面上显示产品属性 - Opencart 3 [英] Display product attributes on category page - Opencart 3

查看:50
本文介绍了在类别页面上显示产品属性 - Opencart 3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have created an attribute called 'Flavour' in opencart 3 and want to display this attribute in the category layout (category.twig) on each product where the title, price, add to cart etc. is.

谢谢

推荐答案

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

Add the below code in your category controller inside products result loop.

'attribute_groups' => $this->model_catalog_installer->getProductAttributes($result['product_id']),

然后在您的 category.twig 页面上添加以下代码以查看特定属性.

Then on your category.twig page add the following codes to view the particular attribute.

{% 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.您可以从管理面板的属性部分进行检查.

please note that you have to replace the 14 on the attribute loop with your exact attribute id. That you can check from the admin panel on attributes section.

希望这能解决您的问题.

hope this will resolve your issue.

这篇关于在类别页面上显示产品属性 - Opencart 3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆