Display category on product page opencart 1.5x

Posted by Flo on 18 Feb 2012

If you want to display the categories a product belongs to on the product page (like the manufacturer is now), here is how you proceed:

In catalog/controller/product/product.php look for the line:


below it add:

//product category


$this->data['catprod'] = array();

$product_category = $this->model_catalog_product->getCategories($product_id);

foreach ($product_category as $prodcat) {

$category_info = $this->model_catalog_category->getCategory($prodcat['category_id']);

if ($category_info) {

$this->data['catprod'][] = array(
'name' => $category_info['name'],
'href' => $this->url->link('product/category', 'path=' . $category_info['category_id'])
//end of product category

In catalog/view/theme/yourtheme/template/product/product.tpl find the line:

<?php if ($manufacturer) { ?>

And above it add:

<span>Categories: </span><?php foreach ($catprod as $catp) { ?> <a href="/<?php echo $catp['href']; ?>"><?php echo $catp['name']; ?></a> |<?php } ?><br />


That is all.