若是從Category產品列表中進入Product,則麪包屑導航中含有Category Path; 不然,當從首頁,或搜索結果中,或者其餘什麼地方進入,則缺乏之。我想,多是Magento支持一個產品放入多個Category的緣故吧。Magento產品頁面包屑導航(Breadcrumb)修正無論怎麼樣,產品頁中缺乏了Category Path,用戶體驗不大好。php
修正的方法,找到文件shell
app/code/core/Mage/Catalog/Helper/Data.php
複製一份到local代碼池app
view sourceprint?1 app/code/local/Mage/Catalog/Helper/Data.php
在函數getBreadcrumbPath的開始部分,加上以下的代碼邏輯函數
public function getBreadcrumbPath() { if ($this->getProduct() && !$this->getCategory()) { $_categoryIds = $this->getProduct()->getCategoryIds(); if ($_categoryId = $_categoryIds[0]) { $_category = Mage::getModel('catalog/category')->load($_categoryId); Mage::register('current_category', $_category); } } 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; }