我用此代码列出了子类别
$root = Mage::getModel('catalog/category')->load(3); // Put your category ID here.
$subCat = explode(',',$root->getChildren());
$collection = $root->getCollection()->addAttributeToSelect("*")->addFieldToFilter("entity_id", array("in", $subCat) );
foreach($collection as $subcategory) {
echo '<a href="'.$subcategory->getURL() .'" />» '.$subcategory->getName().'</a><br/>';
}
我只想显示前3个子类别。我该怎么做?
使用
$collection
// ->addFieldToFilter...
->setPageSize(20)
->setCurPage(1);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句