Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

VKDanger

Newbie
  
  • Posts

    2
  • Joined

  • Last visited

VKDanger's Achievements

Newbie

Newbie (1/14)

  • First Post
  • Conversation Starter
  • Week One Done
  • One Month Later
  • One Year In

Recent Badges

0

Reputation

  1. Приветствую! Переписываю модуль "Рекомендуемые" так, чтобы можно было использовать фильтрацию товаров по категориям. Подключил в контроллер $this->load->model('catalog/category'); Прописал запрос: $query_categories = $this->model_catalog_product->getCategories($product_id); $categories = array(); foreach ($query_categories as $cat) { $ocb_category = $this->model_catalog_category->getCategory($cat['category_id']); $category_info['category_id'] = $ocb_category['category_id']; $category_info['name'] = $ocb_category['name']; $category_info['thumb'] = $ocb_category['image']; $data['categories'][] = $category_info; } ... $data['products'][] = array( 'product_id' => $product_info['product_id'], 'category_id' => $category_info['category_id'], 'category_name' => $category_info['name'], 'category_thumb' => $category_info['thumb'], 'thumb' => $image, 'name' => $product_info['name'], 'description' => utf8_substr(strip_tags(html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('theme_' . $this->config->get('config_theme') . '_product_description_length')) . '..', 'price' => $price, 'special' => $special, 'tax' => $tax, 'rating' => $rating, 'href' => $this->url->link('product/product', 'product_id=' . $product_info['product_id']) ); В twig шаблоне модуля вывод (название категории для наглядности): {% if (categories) %} {% for category in categories %} {% if category.category_id %} {{category.name}} {{category.category_id}} {% endif %} <br> {% endfor %} {% endif %} Но выводит все категории товаров, добавленных в модуль, в каждой карточке товаров (скрин прикрепляю). Подскажите, знатоки, как выводить в каждой карточке ТОЛЬКО соответствующую категорию (у одного товара только одна категория)? Чувствую, что должно быть изящное решение, но кто-то на плече нашёптывает делать костыли, спасайте! =)
×
×
  • 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.