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.
Thanks
Add the below code in your category controller inside products result loop.
'attribute_groups' => $this->model_catalog_installer->getProductAttributes($result['product_id']),
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 %}
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.