Author Topic: Show product images in Joomla search component  (Read 632 times)

Trimud

  • Beginner
  • *
  • Posts: 16
Show product images in Joomla search component
« 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

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4046
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Show product images in Joomla search component
« Reply #1 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

Trimud

  • Beginner
  • *
  • Posts: 16
Re: Show product images in Joomla search component
« Reply #2 on: July 05, 2019, 20:26:44 pm »
Thanks, I'm aware of that, but what this modification should be?

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4046
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Show product images in Joomla search component
« Reply #3 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

Trimud

  • Beginner
  • *
  • Posts: 16
Re: Show product images in Joomla search component
« Reply #4 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; ?>