SQL Script to Set Magento Default Product Images
Set Base, Small and Thumbnail Images with the following SQL Script
One of our magento clients has over 12k products in their catalog. After importing all the product images we discovered that no of them were selected as the default for Base, Small or Thumbnail.
After scouring the internet for a solution we found one over at Stackoverflow, however, the code needed to be adjusted to work with Magento 18.104.22.168.
Simply copy the code below and run it as a SQL query in your database.
Update the following line of code //* AND ev.attribute_id IN (74,75,76); *\\ with your own image attribute numbers found in Magento. Example, my Base Image code is 74, My Small Image code is 75 and my Thumbnail Image Code is 76.
UPDATE catalog_product_entity_media_gallery AS mg, catalog_product_entity_media_gallery_value AS mgv, catalog_product_entity_varchar AS ev SET ev.value = mg.value WHERE mg.value_id = mgv.value_id AND mg.entity_id = ev.entity_id AND ev.attribute_id IN (74,75,76);