Take the 2-minute tour ×
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

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.

share|improve this answer
    
This was a perfect solution, very fast and without any template hacks –  Thomas Nielsen Aug 28 at 8:03

Try comparing the product base image name against the image gallery file name

<?php foreach ($this->getGalleryImages() as $_image): print_r($_image); print_r($product->getImage()); die();?>
    <?php if($_product->getImage() != $_image['file']): ?>
      <li>
         <img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(77); ?>" width="77" height="77" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" />
      </li>
    <?php endif; ?>
<?php endforeach; ?>
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.