Product Configuration – Product Image URL as Part of Collection Load

catalogcollection;configurationproduct

Is it possible to have the product image url loaded as part of the product collection?

for examples:

Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*');

This doesnt add the image.

Best Answer

Do it as such:

$collection = Mage::getModel('catalog/product')->getCollection();

$backendModel = $collection->getResource()->getAttribute('media_gallery')->getBackend();

foreach($collection as $product){
    $backendModel->afterLoad($product); //adding media gallery to the product object
    var_dump($product->getData()); //you should see media gallery information here now
}

This loads the backend model and appends the media gallery attribute for the $product in the loop instead of re-loading the entire product model.