我创建了一个自定义模板(mytheme/template/catalog/navigation/left_parent_category.phtml)来显示当前类别的父类别.
<?php
echo '<div class="box base-mini">';
echo '<ol>';
$currentCat = Mage::registry('current_category');
if ( $currentCat->getParentId() == Mage::app()->getStore()->getRootCategoryId() )
{
// current category is a toplevel category
$loadCategory = $currentCat;
}
else
{
// current category is a sub-(or subsub-, etc...)category of a toplevel category
// load the parent category of the current category
$loadCategory = Mage::getModel('catalog/category')->load($currentCat->getParentId());
}
$subCategories = explode(',', $loadCategory->getChildren());
foreach ( $subCategories as $subCategoryId )
{
$cat = Mage::getModel('catalog/category')->load($subCategoryId);
if($cat->getIsActive())
{
echo '<li><a href="'.$cat->getURL().'">'.$cat->getName().'</a></li>';
}
}
echo '</ol>';
echo …Run Code Online (Sandbox Code Playgroud)