在分类页面下得到当前目录下的所有子目录,并输出! ---当前分类下的所有子分类!

<?php

$layer = Mage::getSingleton('catalog/layer');
$category = $layer->getCurrentCategory();

    if($category->hasChildren()) {
    $ids = $category->getChildren();
    $subCategories = Mage::getModel('catalog/category')->getCollection();
    $subCategories->getSelect()->where("e.entity_id in ($ids)");
    $subCategories->addAttributeToSelect('name');
    $subCategories->load();    foreach ($subCategories AS $item) {
    echo " - " ;
    echo '<a href="'. $item->getUrl() . '">';
    echo $item->getName();
    echo "</a>(";
    echo $item->getProductCount();
    //echo $item->getChildrenCount();
    echo ")";
    echo "<br/>";
    }
    }


?>

你可能感兴趣的:(layer)