Here we have to display all the products from single category using category ID. If we know category ID, We display all the product lists. Category ID is 6. We need to display all the products under 6th category, Use the following code to display all the products,
<?php
$catid = 6;
$category = new Mage_Catalog_Model_Category();
$category->load($catid); //My category id is 6
$prodCollection = $category->getProductCollection();
foreach ($prodCollection as $product) {
$prdIds[] = $product->getId(); //Array to store all the product ids
}
?>
In the above code to get all the products ID from category 6. Then we need to Use following code to get Product information from the $prdIds[] Array.
<?php foreach($prdIds as $product_id); {
$obj = Mage::getModel('catalog/product');
$_product = $obj->load($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();
}?>
Please update your comments to improve Next level in Magento Product Display. Thank you.
2 comments:
Magento beginner Tutorial
I am very thankful to the author to write this fruitful information.It is worth sharing for other users.Thanks once again..
Ecommerce Website Design and Development Company In Bangalore|Magento Ecommerce website Development company
Post a Comment