How to get all products from a particular category id in magento

While i was working on magento ,I had one requirement that how to get all product under a particular category id.I got the id of that particular category.Now I wrote the following code to get all product under that category id.

My category id is

<?php $catid=10 ;?>

I go all product by writing the below code

$category = new Mage_Catalog_Model_Category();
$category->load($catid); //My cat id is 10
$prodCollection = $category->getProductCollection();
foreach ($prodCollection as $product) {
$prdIds[] = $product->getId(); ///Store all th eproduct id in $prdIds array

Now you have all the product ids in $prdIds variable. Just click here to get all details of the product from a particular product id.You can get individual product id by the following loop.

<?php foreach($prdIds as $_prdIds){
// In each loop one by one product id will be assign in between this loop Fetch all data of the particular product id.To get this click here

No comments:

Post a Comment