Перейти до вмісту
Пошук в
  • Детальніше...
Шукати результати, які ...
Шукати результати в ...

Вывод определенных атрибут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 %}   

 

Надіслати
Поділитися на інших сайтах


  В 18.09.2019 в 19:17, helen2014 сказав:

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

ocStore 3.0.2.0

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

 

Expand  

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

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

 

  • +1 2
Надіслати
Поділитися на інших сайтах

Типа такого что-то?

                 {% if attribute.id == '1' or attribute.id == '2' %}
                  <td>{{ attribute.name }}</td>
                  <td>{{ attribute.text }}</td>
                 {% endif %}

 

Надіслати
Поділитися на інших сайтах

  В 18.09.2019 в 20:09, PaulKravchenko сказав:

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

Expand  

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

Надіслати
Поділитися на інших сайтах


  В 18.09.2019 в 20:14, Blast сказав:

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

Expand  

Так работает! Спаибо!

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

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

Надіслати
Поділитися на інших сайтах


  В 18.09.2019 в 20:19, helen2014 сказав:

Так работает! Спаибо!

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

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

Expand  

{% if attribute.attribute_id in [13, 14, 15] %}

Надіслати
Поділитися на інших сайтах

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

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

Expand  

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

Надіслати
Поділитися на інших сайтах


  • 4 months later...
  • 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 %}  

Надіслати
Поділитися на інших сайтах


  • 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>

 

Змінено користувачем Igor112
Надіслати
Поділитися на інших сайтах


  В 05.06.2021 в 09:43, 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>
Expand  

 

{% if attributeColumn.attribute_group_id == 'ид_категории_Характеристики' %} 
Надіслати
Поділитися на інших сайтах

  В 05.06.2021 в 12:57, Blast сказав:

 

{% if attributeColumn.attribute_group_id == 'ид_категории_Характеристики' %} 
Expand  
 <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>

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

Надіслати
Поділитися на інших сайтах


  В 06.06.2021 в 16:24, 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>

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

Expand  

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

{% for attribute in attributeColumn.attribute %}

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

Надіслати
Поділитися на інших сайтах

  • 3 weeks later...

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

Надіслати
Поділитися на інших сайтах


  В 22.06.2021 в 12:31, configurator сказав:

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

Expand  

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

Надіслати
Поділитися на інших сайтах


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

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

Добавить:
 

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

Так?

Надіслати
Поділитися на інших сайтах


  • 1 year later...

Здравствуйте. Не могу никак вывести атрибуты определенной группы в карточке.

	{% for attribute_group in attribute_groups %}
							<h4 class="heading"><span>{{ attribute_group.name }}</span></h4>
							<div class="product-data">
								{% for attribute in attribute_group.attribute %}
									<div class="product-data__item">
										<div class="product-data__item-div">{{ attribute.name }}</div>
										<div class="product-data__item-div">{{ attribute.text }}</div>
									</div>
								{% endfor %}
							</div>
						{% endfor %}

 

Надо как-то по id группы сделать

Змінено користувачем dizastill
Надіслати
Поділитися на інших сайтах


  В 27.10.2022 в 10:23, dizastill сказав:

Здравствуйте. Не могу никак вывести атрибуты определенной группы в карточке.

	{% for attribute_group in attribute_groups %}
							<h4 class="heading"><span>{{ attribute_group.name }}</span></h4>
							<div class="product-data">
								{% for attribute in attribute_group.attribute %}
									<div class="product-data__item">
										<div class="product-data__item-div">{{ attribute.name }}</div>
										<div class="product-data__item-div">{{ attribute.text }}</div>
									</div>
								{% endfor %}
							</div>
						{% endfor %}

 

Надо как-то по id группы сделать

Expand  
{% if attribute_group.attribute_group_id == 'ид_нужной_группы' %} 
Надіслати
Поділитися на інших сайтах

Створіть аккаунт або увійдіть для коментування

Ви повинні бути користувачем, щоб залишити коментар

Створити обліковий запис

Зареєструйтеся для отримання облікового запису. Це просто!

Зареєструвати аккаунт

Вхід

Уже зареєстровані? Увійдіть тут.

Вхід зараз
  • Зараз на сторінці   0 користувачів

    • Ні користувачів, які переглядиють цю сторінку
×
×
  • Створити...

Important Information

На нашому сайті використовуються файли cookie і відбувається обробка деяких персональних даних користувачів, щоб поліпшити користувальницький інтерфейс. Щоб дізнатися для чого і які персональні дані ми обробляємо перейдіть за посиланням . Якщо Ви натиснете «Я даю згоду», це означає, що Ви розумієте і приймаєте всі умови, зазначені в цьому Повідомленні про конфіденційність.