M
M
Minusator2022-04-22 08:27:08
opencart
Minusator, 2022-04-22 08:27:08

How to display first 3 attributes in opencart 3?

Good day.

I display short attributes from the group in the product card with this code

{% if attribute_groups %}
  % for attribute_group in attribute_groups %}
  {% if attribute_group.attribute_group_id == 10   %}
    {% for attribute in attribute_group.attribute %}
    <span>{{ attribute.name }}</span> {{ attribute.text }}<br />
         {% endfor %}
  % endif %}
   {% endfor %}
{% endif %}


How to display only the first 3 product attributes?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Minusator, 2022-04-22
@Minusator

Resolved the issue. I think it will come in handy, who wants to display short attributes

{% if attribute_groups %}
            {% for attribute_group in attribute_groups %}
              {% if attribute_group.attribute_group_id == 10   %}
                {% for attribute in attribute_group.attribute|slice(0,3) %}
                  <span>{{ attribute.name }}</span> {{ attribute.text }}<br />
                {% endfor %}
              {% endif %}
            {% endfor %}
          {% endif %}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question