0

As i browse through categories and subcategories enter image description here

i can see the full breadcrumb. [Home > Electronics > Smartphone]

But as i enter the product listing page (After i selected apple)

enter image description here

i can't see that full breadcrumb. It only shows parent categories. [Home > Electronics]

Problem : how to get full categories and subcategories breadcrumb in my case [Home > Electronics > Smartphone > Apple]

1 Answer 1

1

Assuming your product only belongs to one category. You could override the getBreadcrumbPath function in Mage_Catalog_Helper_Data in this way:

if (!$this->_categoryPath) {

   $path = array();
   $category = $this->getCategory();

   if(!$category && $this->getProduct()) {

      $categoryIds = $this->getProduct()->getCategoryIds();
      if (is_array($categoryIds) and count($categoryIds)) 
          $category = Mage::getModel('catalog/category')->load(array_pop($categoryIds));
   }

   if ($category) {
   ...

Untested, but it should work

4
  • Assuming your product only belongs to one category. what is suppose to means ? if any products in the list belongs to more than one category i don't get full breadcrumb. is that ?
    – Suman K.C
    Commented Jan 29, 2015 at 10:33
  • You would still get the full breadcrumb, but this script arbitrarily picks the last category ID assigned to the product. Commented Jan 29, 2015 at 10:55
  • Replaced, but still shows the same breadcrumb :(
    – Suman K.C
    Commented Jan 29, 2015 at 11:01
  • @K.C. Past that point, I would need to have a nosy to be able to help you. Are you sure you overrode the helper properly? Add an exit in there to make sure it goes through it. Commented Jan 29, 2015 at 15:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.