I added an extra category but i don't want to show this in the breadcrumb.
I searched for a while how i can remove a part from it and found the following solution:
In app/code/local/Mage/Page/Block/Html/Breadcrumbs.php
I added the following code:
function removeCrumb($crumbName) {
if ((!isset($this->_crumbs[$crumbName])) || (!$this->_crumbs[$crumbName]['readonly'])) {
unset($this->_crumbs[$crumbName]);
}
return $this;
}
Then ,i added the following code in app/code/local/Mage/Catalog/Block/Product/View.php
after
$this->getLayout()->createBlock(‘catalog/breadcrumbs’);
$this->getLayout()->getBlock('breadcrumbs')->removeCrumb('home');
Instead of 'home' I can use the word category + the id of the category to remove this part from the breadcrumbs.
This all works fine, but unfortunately only on the product page. When I try to do the same in app/code/local/Mage/Catalog/Block/Category/View.php
something strange happens:
instead of 'home - cat1 - cat2
' it becomes 'home - cat2 - cat1'
.
No idea why.
Does someone knows how to solve this problem for the category page?
I'm using magento 1.7.0.2
Best Answer
It would be wiser to rewrite the
Mage_Catalog_Helper_Data
, as it provides the data on what categories will be added to breadcrumbs.Assuming you know how to rewrite that helper class, here's what you have to do:
Mage_Catalog_Helper_Data
.getBreadcrumbPath
method.Copy the original method but modify these lines:
Replace
$YOUR_CATEGORY_ID
variable or set a value for it.EDIT:
In case you don't know how to do a class rewrite
Mage_Catalog_Helper_Data
.getBreadcrumbPath
. It starts with something likepublic function getBreadcrumbPath()
Replace the whole method with this code:
Replace the text
YOUR_CATEGORY_ID
to the actual category ID of the category you want to hide. It should work after that.Please take note that rewrite core classes is extremely not recommended as core files are replaced whenever you update your magento.