I have a custom media image attribute called hover_image as you may understand when a customer hovers on the product image hover_image shows up.

This works with catalog list but when I search for a product the list that comes up does not show the image that I uploaded to hover_image. It shows placeholder that I uploaded for hover_image from system>configuration>catalog

This is the code that I use for displaying hover image in the list.phtml view

 <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image">
    <img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->constrainOnly(FALSE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize(400,600); ?>" width="300" height="400" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" onmouseover="this.src='<?php echo $this->helper('catalog/image')->init($_product, 'hover_image')->constrainOnly(FALSE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize(400,600) ?>';" onmouseout="this.src='<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->constrainOnly(FALSE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize(400,600) ?>';" />

1 Answer 1


Make sure the hover_image attribute is marked as 'Used in product listing'.
Unfortunately, for some reason still unknown to me, you cannot set that flag for media attributes from the backend. But you can do it directly in the db.
Just run this query to identify the attribute id.

SELECT * FROM eav_attribute WHERE attribute_code = 'hover_image'

After getting that id, just run this to this to set the correct flag

UPDATE `catalog_eav_attribute` SET `used_in_product_listing` = 1 WHERE `attribute_id` = {value from above}

Reindex everything and it should work.

I know that can be done from a single query but it's easier to follow this way.

  • thank you. that solves my problem. can I ask you another question. Although I asked this question here you may not have seen it. have you got any idea why do I get this error "SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '2409-0-1' for key 'PRIMARY' " this comes with transaction failed e-mail. people tries to place order but they get an error saying that "we could not complete your order please try again" but order goes through payment taken and we receive this error. if you recreate the product with the id in the error (in this case 2409) problem solves. thank you.
    – Erdem Ece
    May 28, 2014 at 10:22
  • Thanks for this explanation! I thought I went crazy haha Sep 28, 2018 at 13:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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