set default base, thumb, small image to first image.
If you have multiple images per product from your import, Magento might have set the LAST one as the default base, small, and thumb image for all of your products! This can be an issue if you want the FIRST image to be the default!
SQl given below updates your images and makes the FIRST image (order 1) your default BASE, SMALL, and THUMB image for ALL products in your database.
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 (70, 71, 72)
AND mgv.position = 1;
Auto enable thumbs for multi image and auto disable for single image products.
If you’re like me, you want the multi-image products to have thumbnails enabled on the product page, and if you only have 1 image.
Step1 : The first enables all images for thumbnails
UPDATE catalog_product_entity_media_gallery_value SET disabled = 0;
Step2: Then the second disables any thumbnails for images associated to products having only a total count of image.
UPDATE catalog_product_entity_media_gallery_value AS mgv,
(SELECT entity_id, COUNT(*) as image_count, MAX(value_id) AS value_id
FROM catalog_product_entity_media_gallery AS mg
GROUP BY entity_id
HAVING image_count = 1) AS mg
SET mgv.disabled = 1
WHERE mgv.value_id = mg.value_id
Tags: Magento, Magento snippets