目前我有这个让孩子成为一个类别:
$category = Mage::getModel('catalog/category')->load($categoryId);
$childrenIds = $category->getResource()->getChildren($category, true);
然而,它只会让活跃的孩子。有没有办法让所有特定类别的孩子,包括残疾人类别?
答案 0 :(得分:0)
尝试以下代码
$categoryId = 8; // your parent category id
$category = Mage::getModel('catalog/category')->load($categoryId);
$childrenIdsWithInactive = $category->getChildrenCategoriesWithInactive()->getAllIds();
答案 1 :(得分:0)
试试这个:
<?php function getTreeCategories($parentId, $isChild){
$allCats = Mage::getModel('catalog/category')->getCollection()
->addAttributeToSelect('*')
->addAttributeToFilter('parent_id',array('eq' => $parentId));
foreach ($allCats as $category){
$html .= $category->getId().",";
$subcats = $category->getChildren();
if($subcats != ''){
$html .= getTreeCategories($category->getId(), true);
}
}
return $html;
}
$catlistHtml = getTreeCategories("category_id", false); ?>