Php – Magento products by categories

catalogcategoriesmagentoPHPproduct

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

Best Answer

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);