VirtueMart Forum

VirtueMart 2 + 3 => Templating & Layouts => Topic started by: Trimud on June 29, 2019, 23:05:04 pm

Title: Show product images in Joomla search component
Post by: Trimud on June 29, 2019, 23:05:04 pm
Hello,

I have spent a lot of time searching for similar topic but couldn't find anything related.

I want to show product images in Joomla's search results. I'm using standard Virtuemart - Search plugin with latest Joomla 3 and Virtuemart 3.

Can someone help me with this, please?

Thanks in advance
Title: Re: Show product images in Joomla search component
Post by: Studio 42 on June 30, 2019, 23:20:23 pm
Yo have to modify the plugin, if you want display the thumb. No setting exist to display image
Title: Re: Show product images in Joomla search component
Post by: Trimud on July 05, 2019, 20:26:44 pm
Thanks, I'm aware of that, but what this modification should be?
Title: Re: Show product images in Joomla search component
Post by: Studio 42 on July 06, 2019, 01:24:37 am
Sorry, to long to check and explain. See the plugin code and compare with product product module for eg. you should find  the code to add the images
Title: Re: Show product images in Joomla search component
Post by: Trimud on October 13, 2019, 21:32:23 pm
Added the following in template override: templates/<TEMPLATE>/html/com_search/search/default_results.php

Code: [Select]
<?php 
$imgUrl "";

if (isset($result->product_id)) {
$product $productModel->getProduct($result->product_id);
    $productModel->addImages($product,1);

    if (!empty($product->images[0]->file_url_thumb)) {
     $imgUrl '/' $product->images[0]->file_url_thumb;
    } else if (!empty($product->images[0]->file_url)) {
     $imgUrl '/' $product->images[0]->file_url;
    }


}
?>

Then in the same file add the following code where you want to show the image:
Code: [Select]
<?php if (!empty($imgUrl)) : ?>
<img src='<?php echo $imgUrl?>' />
<?php endif; ?>