I have OpenCart 2.x, I'd like to show category names on product grid of category page. I have 2 levels of category Level 1: Electronics Level 2: Electronics > Mobile Phones
I want to display level 1 (parent) category on top of image and level 2 (sub category) below price. Like below picture: category.tpl
I tried editing "category.php" directly but it is not working. in category.php added this code:
if ($category_info) {
$data['parent_cat_info'] = array();
if($category_info['parent_id'] != 0){
$data['parent_cat_info'] = $this->model_catalog_category->getCategory($category_info['parent_id']);
}
and tried to access it in category.tpl
<?php
if($parent_cat_info){
echo $parent_cat_info['category_id'];
echo $parent_cat_info['name'];
}
?>