Feb 26, 2013

Magento: Can’t see product images in category page

Set product image as small image and thumbnail programatically

If you see your images in product detail page but don’t see it in category page, it’s because your product have images (image attribute filled) but not small_image and thumbnail which are required to display on category page. If there are only few products you want to set small_image and thumbnail, then it’s easy to go to Manage Products > Individual Product > Images tab > Set small image and thumbnail radio button. But when it comes to hundreds/thousands of products, you better want it programatically way.

Make a file in your Magento root and place the below code in it. Then run that file and you have just copied your Product Image to small image and thumbnail as well!

require 'app/Mage.php';

$products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*');
foreach ($products as $product) {
    if (!$product->hasImage()) continue;
    if (!$product->hasSmallImage()) $product->setSmallImage($product->getImage());
    if (!$product->hasThumbnail()) $product->setThumbnail($product->getImage());
echo 'Finished!';


  • Very nice Info….
    This is helpful to develop maegnto store …

  • Hi Kalpesh, I just wanted to say I appreciate your blog. It is nice of you to document things you have discovered in Magento. I just read your post about states vs. statuses and found it to be helpful.

  • Very helpful post…..

    Thanks Kalpesh

  • Please let me know the file name….

Leave a comment


Welcome to my Blog

Kalpesh MehtaHelping Magento developers in their day-to-day development problems since 2011. Most of the problems and solutions here are my own experiences while working on different projects. Enjoy the blog and don't forget to throw comments and likes/+1's/tweets on posts you like. Thanks for visiting!




Magento top 50 contributors

Magento top 50 contributors