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

persol27

Newbie
  
  • Posts

    4
  • Joined

  • Last visited

Everything posted by persol27

  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) появляется ошибка.
×
×
  • 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.