Drmjo Drmjo - 11 days ago 6
PHP Question

Magento original image resize only shows placeholder image

I am trying to get this piece of code to work in magento 1.7.0...

it only displays the magento placeholder image...

if i change "image" to "small_image" it works fine

everything is set up in the back end the radio buttons are selected for the product images... I have cleared the cache also...

this is happening in the list.phtml file ...

can someone kind enough tell me what i am doing wrong or WHY its not working... i have been searching all over i found one solution after 3 days of searching and it didn't work....

$_item is not defined so a i get a call to a non object error...

here's a link to the answere

Get base product image in Magento

<?php echo $this->helper('catalog/image')->init($_product, 'image')->resize(171, 259);

Answer

I would try either...

a) Adding addAttributeToSelect('image') to the product collection in your List Block (assuming it's local).

...or... (Warning: this is hacky and not best practice)

b) In your list.phtml file, load the full product from the product ID you already have

$productId = $_product->getId();
$_product = Mage::getModel('catalog/product')->load($productId);
echo $this->helper('catalog/image')->init($_product, 'image')->resize(171, 259);
Comments