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


$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 '';
    echo $item->getName();
    echo "
(";
    echo $item->getProductCount();
    //echo $item->getChildrenCount();
    echo ")";
    echo "
";
    }
    }


?>

你可能感兴趣的:(在分类页面下得到当前目录下的所有子目录,并输出! ---当前分类下的所有子分类!)