View Single Post
  #5  
Old 02-07-2020, 12:06 PM
  The Knotty Celt's Avatar 
The Knotty Celt The Knotty Celt is offline
 

Advanced Member
  
Join Date: Jan 2020
Posts: 32
 

Smile Re: How to display product image as product thumbnail instead of default product variant.

Thanks again, for your quick and informative reply.


I actually managed to solve the problem without having to write my own module to override the functions of the ProductVariants addon. Instead I created a custom template to override theme_tweaker/customer/items_list/product/parts/common.product-thumbnail.twig
Code:
<a href="{{ this.getProductURL(this.categoryId) }}" class="product-thumbnail"> {{ widget('\\XLite\\View\\Image', lazyLoad=true, image=this.product.getImage(), maxWidth=this.getIconWidth(), maxHeight=this.getIconHeight(), alt=this.getIconAlt(), className='photo') }} </a>


becomes...


Code:
<a href="{{ this.getProductURL(this.categoryId) }}" class="product-thumbnail"> {{ widget('\\XLite\\View\\Image', lazyLoad=true, image=this.product.getProductImage(), maxWidth=this.getIconWidth(), maxHeight=this.getIconHeight(), alt=this.getIconAlt(), className='photo') }} </a>


Essentially replacing the function call this.product.getImage() with this.product.getProductImage().


This changes the behaviour on the front page and category pages, but not on the product listing page itself, which is exactly the behaviour I am after.


Thank you for pointing me in the right direction. It was in reviewing the function definition you pointed out that I was able to notice the getProductImage() function, and try calling that from the template.
__________________
X-Cart version 5.4.1.46
PHP version 7.4.33
MySQL version 15.1
Apache version 2.4.56
cURL version 7.74.0
Reply With Quote