Thursday, August 09, 2012

addCategoryFilter not working in Magento. How to filter categories in Magento.


I'd tried a lot of things that I'd found around the web... but the only one that worked for me was this one:

$category = Mage::getModel('catalog/product')->setId($catid);

$products = Mage::getModel('catalog/product')
    ->getCollection()
    ->addCategoryFilter($category)
    ->addAttributeToSelect("*")
    ->setOrder('name','asc')
    ->load();


Thanks to the wonderful people at Stackoverflow and this thread: http://stackoverflow.com/questions/9481009/addcategoryfilter-doesnt-work-at-all-in-magento

1 comment:

  1. Awesome awesome! Thnks Man! I'm stuck with this issue for 3 hrs.

    ReplyDelete