Эта байда делается в модели. Эта функция
public function getCategories($parent_id = 0) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "category c LEFT JOIN " . DB_PREFIX . "category_description cd ON (c.category_id = cd.category_id) LEFT JOIN " . DB_PREFIX . "category_to_store c2s ON (c.category_id = c2s.category_id) WHERE c.parent_id = '" . (int)$parent_id . "' AND cd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND c2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND c.status = '1' ORDER BY c.sort_order, LCASE(cd.name)");
return $query->rows;
}
Тут должен работать запрос, типа "SELECT *, (SELECT count(*) FROM " . DB_PREFIX . "products" WHERE cat_id=c.id ) as cnt FROM "...
Например (не опенкарт) у меня имеется такая конструкция
$query="SELECT (SELECT count(*) FROM `#__ose_av_core` WHERE crc='') as no_crc,(SELECT count(*) FROM `#__ose_av_core` WHERE notify='new') as new_file_count,(SELECT count(*) FROM `#__ose_av_core` WHERE notify='danger') as danger_file_count,(SELECT count(*) FROM `#__ose_av_core` WHERE scan=0) as no_scan";