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

Вывод опрегделенных атрибутiов ocStore 3.0.2.0


Recommended Posts

Здравствуйте!

ocStore 3.0.2.0

Помогите вывести атрибуты по id.

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

 

Link to comment
Share on other sites


16 минут назад, helen2014 сказал:

Здравствуйте!

ocStore 3.0.2.0

Помогите вывести атрибуты по id.

 

вывод названия и значения только атрибуи с id=3

{% if attribute.attribute_id == 3 %}
  <tr>
    <td>{{ attribute.name }}</td>
    <td>{{ attribute.text }}</td>
  </tr>
{% endif %}

 

  • +1 2
Link to comment
Share on other sites

2 минуты назад, PaulKravchenko сказал:

@helen2014 покажите код полностью плиз. Не может не рилиить, обязано.

            {% 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>
                {% if attribute.id == '13' or attribute.id == '13' %}
                  <td>{{ attribute.name }}</td>
                  <td>{{ attribute.text }}</td>
                 {% endif %}
                </tr>
                {% endfor %}
                  </tbody>
                {% endfor %}
              </table>

            {% endif %}         

Link to comment
Share on other sites


1 минуту назад, Blast сказал:

{% if attribute.attribute_id == '13' %} 

Да рилииет! Спаипотому что!

а если атрибутов несколько, добавляем через запятую?

{% if attribute.attribute_id == '13,14,15,16' %} 

Link to comment
Share on other sites


  • 10 months later...
  • 4 months later...
В 21.07.2020 в 12:16, nibbl сказал:

всивил не рилииет,  надо еещё что то всивлять в контроллере? 

{% for attribute_group in attribute_groups %}
   {% for attribute in attribute_group.attribute %}
 {% if attribute.attribute_id in [1, 2, 3, 4] %} <!-- тут id атрибутов -->
<td>{{ attribute.name }}</td><!-- тут название атрибуи-->
<td>{{ attribute.text }}</td><!-- тут текст/описание атрибуи -->
   {% endif %}
   {% endfor %}
   {% endfor %}

Link to comment
Share on other sites


  • 4 months later...

В контролер после $data['products'][] = array(
--

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

--

Edited by vsok2007
Link to comment
Share on other sites


  • 1 month later...

У меня не рилииет. 

вот икой код получается? 

    {% 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>
                {% if attribute.id in [17, 73, 34, 35] or attribute.id in [17, 73, 34, 35] %}
                  <td>{{ attribute.name }}</td>
                  <td>{{ attribute.text }}</td>
                 {% endif %}
                </tr>
                {% endfor %}
                  </tbody>
                {% endfor %}
              </table>

            {% endif %}  

Link to comment
Share on other sites


  • 4 weeks later...

Здравствуйте, уважаемые.

 

Помогите пожалуйси. Нужно вывести атрибуты только из категории "Характеристики"

 

<div class="products__tabs-container">
                           {% if (product['attribute_groups']) %}
                            <div class="products__tabs-content js-tabs-content is-active">
                              <div class="products__info">
                                <div class="row">
                                  {% for attributeColumn in product['attribute_groups'] %}
                                    <div class="col-6 col-md-6">
                                      <dl class="products__info-dl">
                                      {% for attribute in attributeColumn %}
                                        <dt>{{ attribute['name'] }}</dt>
                                        <dd>{{ attribute['text'] }}</dd>
                                      {% endfor %}                                      
                                      </dl>
                                    </div>
                                  {% endfor %} 
                                </div>
                              </div>
                            </div>
                           {% endif %}
                          </div>

 

Edited by Igor112
Link to comment
Share on other sites


3 часа назад, Igor112 сказал:

Здравствуйте, уважаемые.

 

Помогите пожалуйси. Нужно вывести атрибуты только из категории "Характеристики"

 

<div class="products__tabs-container">
                           {% if (product['attribute_groups']) %}
                            <div class="products__tabs-content js-tabs-content is-active">
                              <div class="products__info">
                                <div class="row">
                                  {% for attributeColumn in product['attribute_groups'] %}
                                    <div class="col-6 col-md-6">
                                      <dl class="products__info-dl">
                                      {% for attribute in attributeColumn %}
                                        <dt>{{ attribute['name'] }}</dt>
                                        <dd>{{ attribute['text'] }}</dd>
                                      {% endfor %}                                      
                                      </dl>
                                    </div>
                                  {% endfor %} 
                                </div>
                              </div>
                            </div>
                           {% endif %}
                          </div>

 

{% if attributeColumn.attribute_group_id == 'ид_категории_Характеристики' %} 
Link to comment
Share on other sites

В 05.06.2021 в 15:57, Blast сказал:

 

{% if attributeColumn.attribute_group_id == 'ид_категории_Характеристики' %} 
 <div class="products__tabs-container">
                           {% if (product['attribute_groups']) %}
                            <div class="products__tabs-content js-tabs-content is-active">
                              <div class="products__info">
                                <div class="row">
                                  {% for attributeColumn in product['attribute_groups'] %}
								  {% if attributeColumn.attribute_group_id == '8' %} 
                                    <div class="col-6 col-md-6">
                                      <dl class="products__info-dl">
                                      {% for attribute in attributeColumn %}
                                        <dt>{{ attribute['name'] }}</dt>
                                        <dd>{{ attribute['text'] }}</dd>
                                      {% endfor %} 								  
                                      </dl>
                                    </div>
									{% endif %}
                                  {% endfor %} 	
                                </div>
                              </div>
                            </div>
                           {% endif %}
                          </div>

Добавил данный код, теперьь не выводит атрибуты совсем.

Link to comment
Share on other sites


15 часов назад, Igor112 сказал:
 <div class="products__tabs-container">
                           {% if (product['attribute_groups']) %}
                            <div class="products__tabs-content js-tabs-content is-active">
                              <div class="products__info">
                                <div class="row">
                                  {% for attributeColumn in product['attribute_groups'] %}
								  {% if attributeColumn.attribute_group_id == '8' %} 
                                    <div class="col-6 col-md-6">
                                      <dl class="products__info-dl">
                                      {% for attribute in attributeColumn %}
                                        <dt>{{ attribute['name'] }}</dt>
                                        <dd>{{ attribute['text'] }}</dd>
                                      {% endfor %} 								  
                                      </dl>
                                    </div>
									{% endif %}
                                  {% endfor %} 	
                                </div>
                              </div>
                            </div>
                           {% endif %}
                          </div>

Добавил данный код, теперьь не выводит атрибуты совсем.

если для получения атрибутов пользовались синдартной функцией, то должно быть ик

{% for attribute in attributeColumn.attribute %}

а если какой-то самопис, то кто ж знает какая у вас структура данных и как отлилить категорию Характеристики от других

Link to comment
Share on other sites

  • 3 weeks later...

Подскажите, а если нужно вывести выбранные атрибуты только в опрегделенной категории, какую функцию прописать?
Что-то врогде этого: {% if category.category_id == '66' %} ?

Link to comment
Share on other sites


В 22.06.2021 в 17:31, configurator сказал:

Подскажите, а если нужно вывести выбранные атрибуты только в опрегделенной категории, какую функцию прописать?
Что-то врогде этого: {% if category.category_id == '66' %} ?

сформировать нужные данные в зависимости от входных данных в контроллере. в твиге (во вьюхе) вообещё логики по минимуму должно быть. пишите сразу правильно

Link to comment
Share on other sites


А можете подробнее написать? Например сюда (category.php):

$data['products'][] = array(
					'product_id'  => $result['product_id'],

Добавить:
 

$data['products'][] = array(
					'product_id'  => $result['product_id'],
                    'category_id'  => $result['product_categoryid'],

Да?

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.