Jump to content
  • разработка интернет магазинов на opencart
  • доработка интернет магазинов на opencart

Добавить вывод атрибутов в категории


Recommended Posts

Доброго времени суток. Как в ocStore 3.0.2.0 вывести атрибуты товаров в категориях? Попыился ик:

В catalog/controller/product/category.php

После

 

'product_id'  => $result['product_id'],

Добавил
  

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


В catalog/view/theme/*/template/product/category.twig

Добавил вывод 

    

            {% if attribute_groups %}
              <table class="table table-bordered">
                {% for attribute_group in 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>
            {% endif %}

 

Edited by Valery332
Link to comment
Share on other sites


On 7/27/2020 at 6:05 PM, spectre said:

 

надо product.attribute_groups

Можете подсказать, как вывести только опрегделенные атрибуты по ID? Думаю многим полезно бугдет.

Link to comment
Share on other sites


  • 1 year later...
31.07.2020 в 15:16, DeMs сказал:

Можете подсказать, как вывести только опрегделенные атрибуты по ID? Думаю многим полезно бугдет.

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

Вместо id всивляете id своего аттрибуи

Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.