0

Created products subcategory want to display all the products that are listed in the category.

The below snippet gives me single product details, I want all the products listed

<?php
$model = Mage::getModel('catalog/product'); //getting product model

$_product = $model->load($productid); //getting product object for particular product id

echo $_product->getShortDescription(); //product's short description
echo $_product->getDescription(); // product's long description
echo $_product->getName(); //product name
echo $_product->getPrice(); //product's regular Price
echo $_product->getSpecialPrice(); //product's special Price
echo $_product->getProductUrl(); //product url
echo $_product->getImageUrl(); //product's image url
echo $_product->getSmallImageUrl(); //product's small image url
echo $_product->getThumbnailUrl(); //product's thumbnail image url   

?>
  • 1
    You can get product collection with your category filter and then display required information on your page. – Jaimin Sutariya Jun 19 '17 at 7:00
  • @JaiminSutariya could you provide code snippet? – ben Jun 21 '17 at 5:10
  • 1
    below answer has the code you can use to get products with category filter. – Jaimin Sutariya Jun 21 '17 at 5:33
2

You can get all product with the current category or you can pass the category id in below code.

$category = Mage::registry('current_category');
    if (empty($category)) {
    $product = Mage::registry('current_product');
    $categoryId = reset($product->getCategoryIds());
    $category = Mage::getModel('catalog/category')->load($categoryId); // you can pass category ID also.
}

$collection = Mage::getResourceModel('catalog/product_collection')
    ->setStoreId(Mage::app()->getStore()->getId())
    ->addCategoryFilter($category);

This may be help.

EDIT

click here

  • can you suggest me a free bootstrap magento 1.9 x theme? – ben Jun 21 '17 at 5:15
  • 1
    I edit my answer and you can see demo and download the themes – ARVIND KARKAR Jun 21 '17 at 9:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.