I am using this code in latest_content.tpl
file to get category name. But it is not displaying category name. How can I get category name in opencart.
$categories = $this->model_catalog_product->getCategories($product_id);
if ($categories)
$categories_info = $this->model_catalog_category->getCategory($categories[0]['category_id']);
$this->data['category_title'] = $categories_info['name'];
echo echo $category_title;
In
catalog/controller/module/latest.php
, before$this->data['products'][] = array(
add:Update
$this->data['products'][]
array as below:Now in
latest.tpl
, you'll get the category title as$product['category_title']
.Additional information: - Model functions should be called within controllers. The variables defined
$this->data['variable_name']
in controller can be accessed in template file as$variable_name
.Have a niceday !!