Tuesday, April 3, 2012

Magento change main image to any product picture on mouse over

Magento change main image to any product picture on mouse over Magento eCommerce Product image change on hover: mouseover: Magento have default feature that when u click on the product image it will get opened in new window so now you can show the product image into the main image on mouseover or on mouse

 click just search the code in app/design/frontend/default/yourtheme/catalog/product/view/media.phtml

<li><a href="#" onclick="popWin('<?php echo $this->getGalleryUrl($_image) ?>', 'gallery', 'width=300,height=300,left=0,top=0,location=no,status=yes,scrollbars=yes,resizable=yes'); return false;" title="<?php echo $this->htmlEscape($_image->getLabel()) ?>"><img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(56); ?>" width="56" height="56" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" /></a></li>

and repalce with

<li><a href="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile()); ?>" title="<?php echo $this->getName();?>" onmouseover="$('image').src = this.href; return false;" onclick="$('image').src = this.href; return false;"><img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(56); ?>" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" title="<?php echo $this->htmlEscape($_image->getLabel()) ?>" /></a></li>

this will show the thumbnail image into the main image on mouse over and on mouse click

11 comments:

  1. Any Demo available for this post ???????

    Please contact us
     Renderindia Infotech Bangalore
    magento e commerce development company Bangalore

    ReplyDelete
  2. But it is not work Properly for me!!!! :(

    ReplyDelete
  3. @Anonymous Can u tell me what issues u are facing so that i can check .....

    ReplyDelete
  4. Excellent just implemented it to our site

    ReplyDelete
  5. Thank you for this Sandeep! Do you have a solution to change the main image when an attribute is selected. Lets say, if it was a t-shirt and the red option is chosen, the picture of the red t-shirt will move to the main image area. I'm looking to modify code and not install an extension. Any help would be greatly appreciated! Thanks!

    ReplyDelete
  6. are you using the configurable product ? to show the image base on color....if you don't need to use extension you need to write some java script code and pass the attribute id along with value you have selected to show the images and make sure that images should be there in your database

    ReplyDelete
    Replies
    1. Yeah, I'm using configurable product. I don't want to use an extension cause I would have to re upload all my products again. Each option already has its own images and its all in the database. I tried Simply Configurable products, but since my products weren't uploaded the way the extension wanted, the options weren't showing up. Any resources on where I could learn more about the code and id that your talking about? Thanks!

      Delete
    2. DERRICK can you send me the link so that i can check and suggest you on same ....if not then you can use the color swatches extension which only help your requirement
      http://www.magentocommerce.com/magento-connect/color-swatches-magento-extension.html
      http://www.magentocommerce.com/magento-connect/color-swatches-magento-extension.html

      othrwise you need to make custom module

      Delete
    3. Derrick thanks for reply can you send me mail directly on sandipgulati08@gmail.com ...if you wish

      Delete

Thankyou for your Comments

LinkWithin

Blog has moved, searching new blog...