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

persol27

Новачок
  
  • Публікації

    4
  • З нами

  • Відвідування

Відвідувачі профілю

244 перегляди профілю

persol27's Achievements

Newbie

Newbie (1/14)

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

Recent Badges

0

Репутація

  1. Вывел. Получается, что дополнил 'name' => $category['name'], на 'name' => $category['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''), Потом перед $data['categories'][] = array( добавил $filter_data = array( 'filter_category_id' => $category['category_id'], 'filter_sub_category' => true ); Вот готовый код, если кому-то понадобится: P.S. Скорость загрузки сайта такая же. // Menu $this->load->model('catalog/category'); $this->load->model('catalog/product'); $data['categories'] = array(); $categories = $this->model_catalog_category->getCategories(0); foreach ($categories as $category) { $children_data = array(); if ($category['top']) { // Level 2 $children = $this->model_catalog_category->getCategories($category['category_id']); foreach ($children as $child) { $filter_data = array( 'filter_category_id' => $child['category_id'], 'filter_sub_category' => true ); $children_data[] = array( 'name' => $child['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''), 'href' => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id']) ); } $filter_data = array( 'filter_category_id' => $category['category_id'], 'filter_sub_category' => true ); // Level 1 $data['categories'][] = array( 'name' => $category['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''), 'children' => $children_data, 'column' => $category['column'] ? $category['column'] : 1, 'href' => $this->url->link('product/category', 'path=' . $category['category_id']) ); } } $data['language'] = $this->load->controller('common/language'); $data['currency'] = $this->load->controller('common/currency'); $data['search'] = $this->load->controller('common/search'); $data['cart'] = $this->load->controller('common/cart');
  2. Здравствуйте, возникла такая проблема. Движок: ocStore 2.3.0.2.3. В главном меню необходимо выводить количество товаров в категории. Пр.: Ноутбуки (452) Смартфоны (122). При редактировании header.php (/catalog/controller/common) смог добиться только отображения кол-ва всех товаров. Код header.php: // Menu $this->load->model('catalog/category'); $this->load->model('catalog/product'); $data['categories'] = array(); $categories = $this->model_catalog_category->getCategories(0); foreach ($categories as $category) { if ($category['top']) { // Level 2 $children_data = array(); $children = $this->model_catalog_category->getCategories($category['category_id']); foreach ($children as $child) { $filter_data = array( 'filter_category_id' => $child['category_id'], 'filter_sub_category' => true ); $children_data[] = array( 'name' => $child['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''), 'href' => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id']) ); } // Level 1 $data['categories'][] = array( 'name' => $category['name'], 'children' => $children_data, 'column' => $category['column'] ? $category['column'] : 1, 'href' => $this->url->link('product/category', 'path=' . $category['category_id']) ); } } $data['language'] = $this->load->controller('common/language'); $data['currency'] = $this->load->controller('common/currency'); $data['search'] = $this->load->controller('common/search'); $data['cart'] = $this->load->controller('common/cart'); При замене строки "'name' => $category['name'], " на "'name' => $category['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($data) . ')' : '')," отображается количество товаров во всём магазине. При использовании getTotalProducts($filter_data) появляется ошибка.

×
×
  • Створити...

Important Information

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