2015-02-24 38 views
0

目前的所有的孩子我有这个获得类别的孩子:Magento的:获取一个特定的类别

$category = Mage::getModel('catalog/category')->load($categoryId); 
$childrenIds = $category->getResource()->getChildren($category, true); 

然而,将只得到活泼的孩子。有没有办法让特定类别的所有孩子,包括残疾类别?

+0

你必须编写SQL直接对数据库的能力吗? – 2015-02-24 04:02:02

回答

0

试试下面

$categoryId = 8; // your parent category id  
$category = Mage::getModel('catalog/category')->load($categoryId); 
$childrenIdsWithInactive = $category->getChildrenCategoriesWithInactive()->getAllIds(); 
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); ?>