I am trying to get a collection of products from a category id. A few things I have tried are in the block :
$category = Mage::getModel('catalog/category')->load(123)
->getProductCollection();
and
$category = Mage::getModel('catalog/category')->load(123);
$products = $category->getProductCollection()->addCategoryFilter($category)
->addAttributeToFilter('type_id', 'simple')
->addAttributeToSelect('*');
also tried just doing it from the phtml
$oCatId = Mage::getModel('catalog/category')->load(769);
$products->addCategoryFilter($oCatId);
None of this works but I am not seeing any errors either. I saw another post that seems like the same question : Magento – Get Products from Specific Category but that method did not work for me either. Thanks for any help!
Best Answer
Try this:
Source: http://overlycaffeinated.com/blog/2011/02/get-all-sale-products-from-a-category-in-magento/
This should work because it adds the category filter for you by virtue of already having the category loaded:
Mage_Catalog_Model_Category
Wait, it still doesn't work!
Ok, so you may have larger issues, presumably something overwriting
getProductCollection
. So let's try circumventing that convenience method: