2015-02-24 5 views
0

В настоящее время у меня есть это, чтобы получить ребенок в категории:Magento: Получить все ребенок определенной категории

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

Однако, он будет получать только активные ребенок. Есть ли способ получить всех детей определенной категории, включая категории инвалидов?

+0

У вас есть возможность писать прямой SQL против БД? –

ответ

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); ?>