I want to display the productimage, based on the SKU of the product.

How can I achieve this?

My currenty code in a custom module, that displays the SKU based on the following code:

<?php echo $item->getProduct() ? $item->getProduct()->getSku() : Mage::helper('rma')->getOrderItemLabel($item) ?>

If you have $item object then you can easily get the product image by like this,


But still If you want the product Image based on SKU then you can get it like this,

    $product = Mage::getModel('catalog/product')->loadByAttribute('sku', $item->getProduct()->getSku());


Use this :

$product = Mage::getModel('catalog/product')->loadByAttribute('sku',$_sku);

Keyur Shah first part is correct, but there is no loadBySku method as suggested in 2nd part. For loading products by SKU you should use


To keep the loaded data as small as possible you can add a 3rd parameter with attribute codes you want to load, e.g.

$attributes = array('image', 'thumbnail');
Mage::getModel('catalog/product')->loadByAttribute('sku', $_sku, $attributes);

(Default value for 3rd parameter is '*', so it will load all attributes)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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