Latest Articles
So far this was never an issue, there were problems with uploading modules via the installer because of the ftp connection but you could allways install ocmods without any issue. However, some .. Read More
People had this issue so many times I thought I would write a bit about it. The  types of issues with opencart's 2.x modification system that I identified so far are: 1. Old Vqmod .. Read More
This small tutorial will show you how to manually add custom links to the default top menu in opencart. If you dont want to go trough all the hustle and would like to be able to completly customize.. Read More
To enable seo urls in opencart navigate in admin to system > settings , edit the store and on the server tab of the store settings you will find "Use SEO urls", set it to yes. So far e.. Read More
All Articles

Display category on product page opencart 1.5x

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:

$this->load->model('catalog/product');


below it add:

//product category

$this->load->model('catalog/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.

Posted by Flo

Related Articles

Even if this issue has been fixed for a while in opencart, some people stil seem to have problems with disabling the product count next to the category name in the opencart left category menu, on the top menu's dropdown and on the subcategories from within a category's page. In the most recent versions of opencart there is one simple setting to disable the product count in all those instaces, the setting can be found in admin > system > settings. Edit the main store, go to the option tab and the first setting below the products heading is category product count, set it to ..
0 comments on this article - view comments