я сделал так, и это работает
но думаю слишком много запросов к базе будет
$data['categories'] = array();
$results = $this->model_catalog_category->getCategories($category_id);
foreach ($results as $result) {
$filter_data = array(
'filter_category_id' => $result['category_id'],
'filter_sub_category' => true
);
$data['products_sub'] = array();
$filter_data = array(
'filter_category_id' => $result['category_id'],
'filter_filter' => $filter,
);
$results_products = $this->model_catalog_product->getProducts($filter_data);
foreach ($results_products as $resultproducts) {
if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) {
$price = $this->currency->format($this->tax->calculate($resultproducts['price'], $resultproducts['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
} else {
$price = false;
}
if ((float)$resultproducts['special']) {
$special = $this->currency->format($this->tax->calculate($resultproducts['special'], $resultproducts['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
} else {
$special = false;
}
if ($resultproducts['weight'] > 0) {
$weight = round($resultproducts['weight'], 2) . ' ' . $this->weight->getUnit($resultproducts['weight_class_id']);
} else {
$weight = '';
}
$data['products_sub'][] = array(
'product_id' => $resultproducts['product_id'],
'name' => $resultproducts['name'],
'price' => $price,
'special' => $special,
'quantity' => $resultproducts['quantity'],
'minimum' => $resultproducts['minimum'] > 0 ? $resultproducts['minimum'] : 1,
'location' => $resultproducts['location'],
'weight' => $weight,
);
}
$data['categories'][] = array(
'category_id' => $result['category_id'], /*!!!*/
'name' => $result['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''),
'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '_' . $result['category_id'] . $url),
'products_sub' => $data['products_sub']
);
}