Добрый день! Хочу вывести возле категорий количество товаров.
Сейчас код имеет такой вид:
$product_total = $this->model_catalog_product->getTotalProducts($data);
$total += $product_total;
$children_data[] = array(
'category_id' => $child['category_id'],
'name' => $child['name'] . ($this->config->get('config_product_count') ? ' (' . $product_total . ')' : ''),
'href' => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id'])
);
}
$this->data['categories'][] = array(
'category_id' => $category['category_id'],
'name' => $category['name'] . ($this->config->get('config_product_count') ? ' (' . $total . ')' : ''),
'children' => $children_data,
'href' => $this->url->link('product/category', 'path=' . $category['category_id'])
);
}
Ничего не выводится. Но когда меняю строку
'name' => $category['name'] . ($this->config->get('config_product_count') ? ' (' . $total . ')' : ''),
на
'name' => $category['name'] . ' (' . $product_total . ')',
выводится кол-во. Но везде показывается (0), хотя товар в категориях есть. Подскажите, пожалуйста, что я делаю не так. Версия 1.5.4.1