Even though it is not necessary at all, it is good idea though to put
the category name of the product when the customer is on the product
view page. It is very helpful if you don’t enable your breadcrumb or
you don’t wish to have a breadcrumb at all just a category name only.
The trick is very simple and easy to do. Using the view.phtml file of your theme that can be found on app/design/frontend/your-package/your-theme/template/catalog/product/view.phtml.And if you’re using the default theme, the directory is app/design/frontend/base/default/template/catalog/product/view.phtml.Open it and add the following code:
The trick is very simple and easy to do. Using the view.phtml file of your theme that can be found on app/design/frontend/your-package/your-theme/template/catalog/product/view.phtml.And if you’re using the default theme, the directory is app/design/frontend/base/default/template/catalog/product/view.phtml.Open it and add the following code:
<?php $categories = $_product->getCategoryIds(); ?> <?php foreach($categories as $k => $_category_id): ?> <?php $_category = Mage::getModel('catalog/category')->load($_category_id) ?> <a href="<?php echo $_category->getUrl() ?>"><?php echo $_category->getName() ?></a> <?php endforeach; ?>
No comments:
Post a Comment