Magento corrected the crumb navigation on the product page from the home page. This article will introduce Magento to you how to implement the breadcrumb navigation on the Product page from the homepage. if the Product is from the Category Product list, go to the Product details page, this article introduces Magento to's solution to the browser. if the Product is from the Category Product list, go to the Product details page, the breadcrumb navigation contains the Category Path; otherwise, it is missing when you enter from the homepage, search results, or somewhere else. I think it may be because Magento supports multiple Category for one product. In any case, the product page lacks the Category Path, and the user experience is poor.
Find the app/code/core/Mage/Catalog/Helper/Data. php file.
Copy a copy to the local code pool
App/code/local/Mage/Catalog/Helper/Data. php
Add the following code logic to the start part of the getBreadcrumbPath function:
| The code is as follows: |
|
GetBreadcrumbPath ()
{
If (! $ This-> _ categoryPath ){
$ Path = array ();
// Add by date 2013-04-07 product page bread navigation correction
If ($ this-> getProduct ()&&! $ This-> getCategory ()){
$ _ CategoryIds = $ this-> getProduct ()-> getCategoryIds ();
Rsort ($ _ categoryIds );
If ($ _ categoryId = $ _ categoryIds [0]) {
$ _ Category = Mage: getModel ('catalog/category ')-> load ($ _ categoryId );
Mage: register ('current _ category ', $ _ category );
}
}
// End date 2013-04-07
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;
} |
First, determine whether the current product page is used. if there is no Category information, obtain the Category IDs to which the product belongs. one product in Magento can be added to multiple Category, select only one of the lucky Category as current_category.
Corrected the implementation method of the breadcrumb navigation on the Product page from the homepage. if the Product is from the Category Product list to enter the Product details page, then the breadcrumb navigation...