Load products by category ID

Tweet, share & co

tweet fb share g+ share

Tags


Description

Load products by category ID, for example 12.

Code

$_category = Mage::getModel('catalog/category')->load(12);
$_productCollection = $_category->getProductCollection();
if($_productCollection->count()) {
    foreach( $_productCollection as $_product ):
        echo $_product->getProductUrl();
        echo $this->getPriceHtml($_product, true);
        echo $this->htmlEscape($_product->getName());
    endforeach;
}

Comments