Get all products from a particular category id in magento
My category id is
<?php $catid=10 ;?>
I got all product by writing the below code
<?php
$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){
$product_id = $_prdIds;
$obj = Mage::getModel('catalog/product');
$_product = $obj->load($product_id); // Enter your Product Id in $product_id
// get Product's name
echo $_product->getName();
//get product's short description
echo $_product->getShortDescription();
//get Product's Long Description
echo $_product->getDescription();
//get Product's Regular Price
echo $_product->getPrice();
//get Product's Special price
echo $_product->getSpecialPrice();
//get Product's Url
echo $_product->getProductUrl();
//get Product's image Url
echo $_product->getImageUrl();
}
?>
Hit like or leave comment if post help!
Please support us, Like us on Facebook.
Subscribe to:
Post Comments (Atom)
Nice post ,thanks for sharing ,keep posting articles like this .
ReplyDeleteMagento Developers