Ok, Let me share How i figured this out -
I actually couldn't share because i figured out only for in my own need while I don't really understand how it works, so couldn't really post codes and explain, but now I see how it did.
First of all, you will need to find an open resourse of javascript that does image rollover in .js file format.
I can not share js file i currently am using because im not sure if im allowed to share this one, but i'm pretty sure there are many free js source that do rollover image.
or I found this :
http://jehiah.cz/a/simple-swap (download js file i=on the bottom of page), this seems working similar with the one I have.
So let me just post pretending im using that js above.
1. download above js file and upload it in your catalog theme folder.
for example, i placed my js file in catalog/view/theme/*your theme*/js/simpleswap.js
2.open catalog/controller/product/category.php
and find
Code: Select all
$image = $this->model_tool_image->resize($result['image'], $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height'));
} else {
$image = false;
}
then add this
Code: Select all
$images = $this->model_catalog_product->getProductImages($result['product_id']);
if(isset($images[0]['image']) && !empty($images[0]['image'])){
$images =$images[0]['image'];
}
Find
Code: Select all
$this->data['products'][] = array(
'product_id' => $result['product_id'],
'thumb' => $image,
And Add
Code: Select all
'thumb_swap' => $this->model_tool_image->resize($images, $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height')),
3. Open catalog/view/theme/*yourtheme*/template/product/category.tpl
ADD this on very top
Code: Select all
<script language="javascript" src="catalog/view/theme/*yourtheme*/js/simpleswap.js"></script>
(!! put your own location of js file for scr=" "!!)
find
Code: Select all
<?php if ($product['thumb']) { ?>
<div class="image"><a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" title="<?php echo $product['name']; ?>" alt="<?php echo $product['name']; ?>" /></a></div>
<?php } ?>
and replace with
Code: Select all
<?php if ($product['thumb_swap']) { ?>
<div class="image"><a href="<?php echo $product['href']; ?>"><img oversrc="<?php echo $product['thumb_swap']; ?>" src="<?php echo $product['thumb']; ?>" title="<?php echo $product['name']; ?>" alt="<?php echo $product['name']; ?>" style="border:none"/></a></div>
<?php } else {?>
<div class="image"><a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" title="<?php echo $product['name']; ?>" alt="<?php echo $product['name']; ?>" style="border:none"/></a></div>
<?php } ?>
Actually I have not tested this, since i am using different javascript, but as long as there's no error on the script above, this would work
