1) Для начала расширяем модель:
открываем system/engine/model.php и добавляем новый метод
public function getRowValue($table, $colname, $where) {
$sql = 'SELECT t.'.$colname.' FROM '.DB_PREFIX.$table.' t ';
$sql .= ' WHERE t.'.$where.' LIMIT 1';
$query = $this->db->query($sql);
return !empty($query->row)? $query->row[$colname]: '';
}
этот метод будет доступен из любого контроллера и позволит получать одно необходимое нам значение.
2) Теперь открываем catalog/controller/module/featured.php и ищем:
$this->data['products'][] = array(
'product_id' => $product_info['product_id'],
'cid' => $this->model_catalog_product->getRowValue('product_to_category', 'category_id', 'product_id='.$product_info['product_id']),
'ctitle' => '',
'thumb' => $image,
'name' => $product_info['name'],
'price' => $price,
'special' => $special,
'rating' => $rating,
'reviews' => sprintf($this->language->get('text_reviews'), (int)$product_info['reviews']),
'href' => $this->url->link('product/product', 'product_id=' . $product_info['product_id'])
);
заменяем на следующее:
$temp = array(
'product_id' => $product_info['product_id'],
'cid' => $this->model_catalog_product->getRowValue('product_to_category', 'category_id', 'product_id='.$product_info['product_id']),
'ctitle' => '',
'thumb' => $image,
'name' => $product_info['name'],
'price' => $price,
'special' => $special,
'rating' => $rating,
'reviews' => sprintf($this->language->get('text_reviews'), (int)$product_info['reviews']),
'href' => $this->url->link('product/product', 'product_id=' . $product_info['product_id'])
);
if(!empty($temp['cid'])) {
$temp['ctitle'] = $this->model_catalog_product->getRowValue('category_description', 'name', 'category_id='.$temp['cid']);
}
$this->data['products'][] = $temp;
unset($temp);
Таким образом мы получили ID и заголовок категории для каждого товара.