Page 1 of 1

call category name on product details page

Posted: Sat Nov 19, 2011 6:33 pm
by zebdev
Hi there,

I have a list of categories and then you click through to see all the products in that category. Then you click on a product!

How can I show the category name that product is in on the product page?

Thank you

Re: call category name on product details page

Posted: Sat Nov 19, 2011 7:48 pm
by jimmyphong
Open file : catalog/controller/product/product.php

find code (may be in line 28) :

Code: Select all

$category_info = $this->model_catalog_category->getCategory($path_id);
add after :

Code: Select all

$this->data['category_name'] = $category_info['name'];
open product template file :

Code: Select all

catalog/view/theme/default/template/product/product.tpl
and the code any where you wanna show category name :

Code: Select all

<?php if(isset($category_name)) { ?>
		<?php echo $category_name; ?>
	<?php } ?>

Re: call category name on product details page

Posted: Sat Nov 19, 2011 9:43 pm
by zebdev
Excellent thank you - this works perfect.

Re: call category name on product details page

Posted: Fri Dec 23, 2011 6:37 am
by ozmofa
it's not working 1.4.9 sorry why may not seeing in product detail?