Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email

Magento Forum

Problem with fetching product price and image
Jr. Member
Total Posts:  5
Joined:  2008-07-24


I’m writing custom module for magento and I’ve problem with fetching Product price and image.
My code:

public function indexAction()
$storeId Mage_Catalog_Model_Category::DEFAULT_STORE_ID;
$collection Mage::getModel('catalog/product')->getCollection()
$result = array();

        foreach (
$collection as $product{
$result[] = array( // Basic product data
'product_id' => $product->getId(),
'sku'        => $product->getSku(),
'name'       => $product->getName(),
'category_id'=> $product->getCategoryIds(),
'set'        => $product->getAttributeSetId(),
'type'       => $product->getTypeId(),
'price'        => $product->getPrice(),
'url'       => $product->getProductUrl(),
'image'        => (string)Mage::helper('catalog/image')->init($product'image')
foreach($result as $row){
echo "<br />";
Output:, (only one row):

array(9) {
["product_id"] => string(2) “13”
["sku"] => string(10) “F3SG-AP202”
["name"] => string(55) “ASUS F3SG-AP202 T2390/15.4/250GB/2GB/GF9300M/BT/GRATISY”
["category_id"] => array(1) {
[0] => string(2) “14”
["set"] => string(2) “27”
["type"] => string(6) “simple”
["price"] => NULL
["url"] => string(90) “”
["image"] => string(143) “”

The question is, Why the getPrice() method doesn’t work, and Mage::helper(’catalog/image’)->init($product, ‘image’) is fetching default magento image?

Thanks in advance!

Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top