In file app/code/core/Mage/Catalog/Helper/Data.php
you will find getBreadcrumbPath()
function in which they look for the Mage::registry('current_category')
public function getBreadcrumbPath()
{
if (!$this->_categoryPath) {
$path = array();
if ($category = $this->getCategory()) {
$pathInStore = $category->getPathInStore();
$pathIds = array_reverse(explode(',', $pathInStore));
$categories = $category->getParentCategories();
// add category path breadcrumb
foreach ($pathIds as $categoryId) {
if (isset($categories[$categoryId]) && $categories[$categoryId]->getName()) {
$path['category'.$categoryId] = array(
'label' => $categories[$categoryId]->getName(),
'link' => $this->_isCategoryLink($categoryId) ? $categories[$categoryId]->getUrl() : ''
);
}
}
}
if ($this->getProduct()) {
$path['product'] = array('label'=>$this->getProduct()->getName());
}
$this->_categoryPath = $path;
}
return $this->_categoryPath;
}
in if
condition
public function getCategory()
{
return Mage::registry('current_category');
}
As you are going from the home page that time Mage::registry('current_category')
is not set thats why category path is not getting display.
if your url is mystore.com/category/product-name
then it will display breadcrumb
As you mentioned I want force always show the category of this product.
Solution :
You can set current_category
before product page loads but Product can be from multiple categories.
OR
create template file create the product list and set anchor by full product url.
OR
Edit in core file app/code/core/Mage/Catalog/Helper/Data.php
(not good practice and its abstract file)