magento产品详情页增加面包屑分类导航

app\code\core\Mage\Catalog\Block\Breadcrumbs.php文件拷贝到local目录,并对这个文件做修改:

function _prepareLayout内,$title = array();之前,插入以下代码即可生效。

$current_category   = Mage::registry('current_category');
$current_product    = Mage::registry('current_product');
if(!$current_category && $current_product){
	$categories = $current_product->getCategoryCollection()->addAttributeToSelect('name')->setPageSize(1);
	foreach($categories as $category) {
		Mage::unregister('current_category');
		Mage::register('current_category', $category);
	}
}


你可能感兴趣的:(magento,php)