В опенкарт есть контроллер:
catalog/controller/extension/module/category.php
Получаю в цикле там товары так:
foreach ($categories as $category) {
$children_data = array();
if ($category['category_id'] == $data['category_id']) {
$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(
'category_id' => $child['category_id'],
'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
);
$data['categories'][] = array(
'category_id' => $category['category_id'],
'name' => $category['name'] . ( !isset( $data['is_home'] ) && $this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''),
'children' => $children_data,
'href' => $this->url->link('product/category', 'path=' . $category['category_id'])
);
$products_home = $this->model_catalog_product->getProducts( $filter_data['filter_category_id'] );
foreach ( $products_home as $product_home ) {
$data['products_home'][] = array(
'name' => $product_home['name'],
'href' => $this->url->link('product/product', 'product_id=' . $product_home['product_id'])
);
}
}
Но так выводятся все товары:
Как мне в цикле итерации связать их и добавить в массив, например как в данном примере ?
Дело в том, что в массиве товара нету ключа cat_id или category_id