Display the full breadcrumb path on product page

Magento’s product page doesn’t always display the full breadcrumb path on the product page (for example, it may be missing the category trail). Here’s a simple modification to remedy it.

Copy: app/code/core/Mage/Catalog/Block/Breadcrumbs.php

TO: app/code/local/Mage/Catalog/Block/Breadcrumbs.php

Add the following code in the _prepareLayout function (as noted by the mod comments:)

protected function _prepareLayout()
if ($breadcrumbsBlock = $this->getLayout()->getBlock('breadcrumbs')) {
$breadcrumbsBlock->addCrumb('home', array(
'title'=>Mage::helper('catalog')->__('Go to Home Page'),

// MOD to add the full category breadcrumb path.
$current_category = Mage::registry('current_category');
$current_product = Mage::registry('current_product');

if(!$current_category && $current_product){
$categories = $current_product->getCategoryCollection()->addAttributeToSelect('name')->setPageSize(1);
foreach($categories as $category) {
Mage::register('current_category', $category);
// end MOD
$title = array();
$path = Mage::helper('catalog')->getBreadcrumbPath();

foreach ($path as $name => $breadcrumb) {
$breadcrumbsBlock->addCrumb($name, $breadcrumb);
$title[] = $breadcrumb['label'];

if ($headBlock = $this->getLayout()->getBlock('head')) {
$headBlock->setTitle(join($this->getTitleSeparator(), array_reverse($title)));
return parent::_prepareLayout();

After clearing your cache, you should notice the full path is now being displayed


  1. By Fernando

  2. By Francesco

  3. By kusum

  4. By Mahmut

  5. By Vikram

  6. By Javier

  7. By Taro

  8. By sidlo

Leave a Reply