0

For this site I need the product images from the homepage or the category page to link to the product. Right now when you click on a product image it doesn't link to the product page. It does nothing. You have to click the name of the product in order to get to the product page. Anyone know a way to do this with reference to where to put the necessary code. I was thinking something with xml files but i am not sure which file and where it is located....

Thanks for the help...

  • the theme i was using had a css conflict which made the product image not a link but its fixed now – jstayfaded Mar 28 '16 at 19:48
0

You would need to give more info, like what template are you using, or if you are just using the regular default template, below is where the general location of the file would be, hopefully it points you in the right direction - also I need to mention that it is recommended to extend your theme, so that you don't make edits to the original template and lose your changes during an update.

Depending on what theme you are using for magento, you would need to edit the file located here:

app/design/frontend/yourpackage/yourtheme/template/catalog/product/list.phtml

you will need to make your edits in two places, you will notice an if/else statement that designates whether the listing will show as grid or list mode. just edit both places to be safe. Look for something like this:

<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135); ?>" width="135" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />

The above code spits out the image.

Then you need to wrap it in your anchor tag:

<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image">

Don't forget to close your anchor tag after the image code.

From my experience, most templates already link the image to the product itself, unless you have some kind of error or are using a custom template.

Hope this helps.

0

the theme i was using had a css conflict which made the product image not a link but its fixed now

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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