Magento 1.6 – Skip Main Image in ‘More Views’ Without Using Exclude

imagemagento-1.6media

I want to skip the base image from "More Views" – I know this can be done by exclding the image, but I have 20k+ products, alot of them with multiple pictures. I've tried to skip the first product from the media.phtml but that didn't work since some of the images are not in the correct order.

Could I somehow check for the main image, and skip this?

Best Answer

I know its not the best way to update the database directly, but in this case it might be the fastest way to set all default images to exclude so that you don't need a template hack.

With the following query you will set the base image (attribute image) to exclude (disable=1) in the media gallery:

UPDATE catalog_product_entity_media_gallery_value AS mgv
INNER JOIN catalog_product_entity_media_gallery AS mg ON mgv.value_id=mg.value_id
INNER JOIN catalog_product_entity_varchar AS cpev ON mg.entity_id=cpev.entity_id AND cpev.value=mg.value
INNER JOIN eav_attribute AS ea ON ea.attribute_id=cpev.attribute_id
SET mgv.disabled=1
WHERE ea.attribute_code='image'

Before running the query make sure you have a backup (and test it on your staging/test setup first). Also don't forget to add the table prefix if you are using that. I tested it on the Magento 1.9 sample data and it looks like it works.

Related Topic