0
votes

I am trying to display ONE specific parent category's subcategories on the magento 1.6 front page (in this case the category with the ID 23), but the code always shows ALL existing parent categories and subcategories.

Can anyone point me to the right direction?

<?php $children=Mage::getModel('catalog/category')->getCollection(23)->load(); ?>
<?php $i=0; foreach ($children as $child): ?>
<?php if ($i++%3==0): ?>
<?php endif ?>
<?php $subCategory = Mage::getModel('catalog/category')->load($child->getId()); ?>

<a href="<?php echo $child->getURL() ?>
          " title="<?php echo $this->htmlEscape($child->getName()) ?>"> <?php echo $this->htmlEscape($child->getName()) ?></a> <?php echo $subCategory->getDescription() ?>
<?php if ($i%3==0 && $i!=$_collectionSize): ?>
<?php endif ?>
<?php endforeach ?>
<?php for($i;$i%3!=0;$i++): ?>
<?php endfor ?>
<?php if ($i%3==0): ?>
<?php endif ?>

Thanks

1

1 Answers

0
votes

Do this instead :

Mage::getModel('catalog/category')->load('23')->getChildrenCategories();

and iterate over the result.

and that's how i found it out:

$object = Mage::getModel('catalog/category'); 
print_r(get_class_methods($object));
print_r($object->load('23')->getChildrenCategories()->toArray());