Magento – Remove duplicate product photos

magento-1.7MySQLproduct-images

I need to remove duplicate product photos after an import. Thumbnails were imported as product photos.

The thumbnail filename is based off the main images filename, so I have:

fg60-2.jpg
fg60-2t.jpg

I need a query to look at each products images, and when it finds a product with images like:

xxxx.jpg
xxxxt.jpg

Then the xxxxt.jpg image is removed.

Any MySQL experts have any advice? Were using Magento 1.7

Best Answer

This was already taken care of with a module. Image Clean works with 1.4.2.0 on up to 1.7 and is available over on Magento Connect as a free install.

I recommend it as your issue will be an ongoing one. Magento does not remove images when product are deleted so not only do you have this import issue to contend with every time something goes akilter, but you have an ongoing and never ending disk usage bloat as Magento's less than stellar housekeeping lets it pack on the poundage in unused images from long dead and removed product.

Note: no affiliation with the above mentioned module. However, having tried to go the scripting route to manage images, found that this developer produced a module that works simply and efficiently. Just don't let it delete your placeholder images for "No image found"

Related Topic