Reputation: 2507
I am using dresscode template of magento.It has a module to display products in home page like carousel.If i have click on the product image means the page which redirects shows the breadcrumb as Home -> product name.
I need to change this breadcrumb path to Home -> category -> product name.
How to get this?
My function used to get the breadcrumb path
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()) {
if($this->getProduct()->getproduct_title()!='')
{
$path['product'] = array('label'=>$this->getProduct()->getproduct_title());
}
else
{
$path['product'] = array('label'=>$this->getProduct()->getName());
}
}
$this->_categoryPath = $path;
}
return $this->_categoryPath;
}
Upvotes: 0
Views: 1029
Reputation: 2500
Check following url to acheive above thing.
http://dltr.org/blog/magento/381/Magento-Force-Display-Full-Breadcrumb-Path
Also
Programmatically add breadcrumbs paths in Magento?
Upvotes: 3