Magento products by categories


Question

Does anyone know how I can get a list of products belonging to a specific category from within a view file in Magento?

1
14
9/25/2015 8:09:00 AM

You can use magento object to filter.

Example:

$categoryId = 123; // a category id that you can get from admin
$category = Mage::getModel('catalog/category')->load($categoryId);

$products = Mage::getModel('catalog/product')
    ->getCollection()
    ->addCategoryFilter($category)
    ->load();

print_r($products);
21
8/24/2011 2:54:03 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon