本文共 653 字,大约阅读时间需要 2 分钟。
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 | if ( $category ->hasChildren()) { //判断是否有子目录 $ids = $category ->getChildren(); //提取子目录id清单 $subCategories = Mage::getModel( 'catalog/category' )->getCollection(); $subCategories ->getSelect()->where( "e.entity_id in ($ids)" ); //提取指定目录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/>" ; } } |
转载地址:http://mdcli.baihongyu.com/