I need to get the products from a specific category and display in a specific template style. I know you can do this on a cms page:

{{block type="catalog/product_list" name="product_list" category_id="209" column_count="4"  mode="grid" limit="25"  template="catalog/product/list.phtml"}}

But how can I do this in a php file?

1 Answer 1


You can do a loop through all products in a specific category and just pull back the info you need in the loop. Quick example:


$category = new Mage_Catalog_Model_Category();

$prodCollection = $category->getProductCollection();

foreach ($prodCollection as $product):
  $product_id = $product->getId();
  $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();


EDIT: Can you try this?

->setData('category_id', '209')
->setData('column_count', '4')
->setData('mode', 'grid')
->setData('limit', '25')
->setData('name', 'product_list')
  • thanks, but is there a way to display it like the list.phtml template?
    – hello123
    Commented Sep 14, 2017 at 8:00
  • Updated my answer Commented Sep 14, 2017 at 15:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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