|
Hi there,
I tried that, but got an error. However it did point me in the right direction. So thank-you!
For those that are interested this is what I did which is based on the getStoreCategories function.
left.phtml - 6 is the id of the parent category
<ul> <?php foreach ($this->getSubCategories(6) as $_category): ?> <?php echo $this->drawItem($_category) ?> <?php endforeach ?> </ul>
/Mage/Catalog/Model/Category.php
public function getSubCategories($parentId) { $helper = Mage::helper('catalog/category'); return $helper->getSubCategories($parentId); }
/Mage/Catalog/Helper/Category.php
public function getSubCategories($parentId, $sorted=false, $asCollection=false, $toLoad=true) { $category = Mage::getModel('catalog/category'); /* @var $category Mage_Catalog_Model_Category */ if (!$category->checkId($parentId)) { if ($asCollection) { return new Varien_Data_Collection(); } return array(); }
$tree = $category->getTreeModel(); /* @var $tree Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Tree */
$nodes = $tree->loadNode($parentId) ->loadChildren() ->getChildren();
$tree->addCollectionData(null, $sorted, $parentId, $toLoad, true);
if ($asCollection) { return $tree->getCollection(); } else { return $nodes; } }
Hopefully this helps someone?
|