1
我有4個級別的類別。
例如:
level0category --> level1category --> level2category -->lastlevel_level3cateogory
是否有可能在lastlevel上顯示僅在level2中的類別?
我在想的東西用自動分類檢測,而不必設置CAT_ID =Magento:顯示所有level2類別
編輯(我加載自定義left.phtml塊上):這就是我一直在尋找,從不同的代碼組合後源。
<?php
$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());
// @TODO enhance for more nested category levels to display sub-categories
}
$subCategories = explode(',', $loadCategory->getChildren());
foreach ($subCategories as $subCategoryId)
{
$cat = Mage::getModel('catalog/category')->load($subCategoryId);
if ($cat->getIsActive())
{
if ($currentCat->getEntityId() == $subCategoryId)
{
echo '<li style="display:none;">'.$cat->getName().'</li>';
}
else
{
echo '<a href="'.$cat->getURL().'">'.$cat->getName().'</a> <br>'; }
}
}
?>