$this->load->model('catalog/category');
$this->load->model('catalog/product');
$data['categories'] = [];
$categories = $this->model_catalog_category->getCategories(0);
foreach ($categories as $category) {
$category_products = [];
$filter = [
'filter_category_id' => $category['category_id'],
'filter_sub_category' => false, // поставить true если нужно учитывать подкатегории
'start' => 0,
'limit' => 3
];
$products = $this->model_catalog_product->getProducts($filter);
if (!empty($products)) {
foreach ($products as $product) {
$category_products[] = [
'name' => $product['name'],
'product_id' => $product['product_id'],
];
}
}
$data['categories'][] = [
'products' => $category_products,
'category_id' => $category['category_id'],
'name' => $category['name'],
'href' => $this->url->link('product/category','path='.$category['category_id'])
];
}
как то так