Display all products

<?php

$collection = Mage::getModel(‘catalog/product’)->getCollection()

->addAttributeToSelect(‘*’) // select all attributes

->setPageSize(10) // limit number of results returned

->setCurPage(4); // set the offset (useful for pagination)

 

 

// we iterate through the list of products to get attribute values

foreach ($collection as $product) {

echo ‘<br />Name :’;

echo $product->getName(); //get name

echo ‘<br />Price : ‘;

echo (float) $product->getPrice(); //get price as cast to float

echo ‘<br />Description : ‘;

echo $product->getDescription(); //get description

echo ‘<br />Shor Description : ‘;

echo $product->getShortDescription(); //get short description

echo ‘<br /> Product type :’;

echo $product->getTypeId(); //get product type

echo ‘<br /> Product Status : ‘;

echo $product->getStatus(); //get product status

 

// getCategoryIds(); returns an array of category IDs associated with the product

foreach ($product->getCategoryIds() as $category_id) {

$category = Mage::getModel(‘catalog/category’)->load($category_id);

echo ‘<br />Category Name :’;

echo $category->getName();

echo ‘<br />Parent Category :’;

echo $category->getParentCategory()->getName(); // get parent of category

echo ‘<br />’;

}

//gets the image url of the product

echo ‘<br />Image URL :’;

echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).

‘catalog/product’.$product->getImage();

echo ‘<br />Special Price :’;

echo $product->getSpecialPrice();

echo ‘<br />Product URL :’;

echo $product->getProductUrl();  //gets the product url

echo ‘<br />’;

} ?>