I have been trying to get specifications/attrributes to shoe on Category page in the product panel ender description.
This is a solution to a similar and particular problem: Display product attributes on category page - Opencart 3
I have tried to adapt it to my needs but unsuccessful.
I have put this in the category controller page:
'attribute_groups' => $this->model_catalog_installer->getProductAttributes($result['product_id']),And in the Category Twig page:
{% if product.attribute_groups %}
{% for attribute_group in product.attribute_groups %}
{% for attribute in attribute_group.attribute %}
{{ attribute.name }}
{{ attribute.text }}
`The result is that the attributes do not appear and I get no errors.
Can anyone suggest how I can achieve this? Any help as always appreciated.
Hi Daniel, The following code that worked was in catalog\controller\product\catefory.php:
'attribute_groups' =>$this->model_catalog_product->getProductAttributes($result['product_id']),
after
$data['products'][] = array(
'product_id' => $result['product_id'],
'thumb' => $image,
'name' => $result['name'],
'description' => utf8_substr(trim(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'))), 0, $this->config->get('theme_' . $this->config->get('config_theme') . '_product_description_length')) . '..',`
Then in the catalog\view\theme\default\template\product\category.twig:
{% if product.attribute_groups %} <div class="tab-pane" id="tab-specification"> <table class="table table-bordered">
{% for attribute_group in product.attribute_groups %}
<thead>
<tr>
<td colspan="2"><strong>{{ attribute_group.name }}</strong></td>
</tr>
</thead>
<tbody>
{% for attribute in attribute_group.attribute %}
<tr>
<td>{{ attribute.name }}</td>
<td>{{ attribute.text }}</td>
</tr>
{% endfor %}
</tbody>
{% endfor %} </table></div>{% endif %}
after
<div>
<div class="caption">
<h4><a href="{{ product.href }}">{{ product.name }}</a></h4>
<p>{{ product.description }}</p>
Hope this helps others..