VirtueMart Forum

VirtueMart 2 + 3 + 4 => 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

<?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:
<?php if (!empty($imgUrl)) : ?>
<img src='<?php echo $imgUrl?>' />
<?php endif; ?>
Title: Re: Show product images in Joomla search component
Post by: EIF on June 21, 2021, 22:30:57 PM
I am trying to get this to work, but the joomla search only displays the title of the product with the SKU between ( ).
Seems like the code is not working. Or do I need to put it on a exact line?
Title: Re: Show product images in Joomla search component
Post by: marvays on April 11, 2022, 19:44:57 PM
In plugins/search/virtuemart/virtuemart.php I can delete blank () for SKU.
But i dont know how add image.

I try to templates/<TEMPLATE>/html/com_search/search/default_results.php too, but not work.
Title: Re: Show product images in Joomla search component
Post by: pinochico on April 12, 2022, 00:43:20 AM
add to plugin model for product
call function for add images for selected product
show images for product (thumb or full) by if/else test

what is different Martin?

Why don't you search right code in view.html.php for view productdetail?
In this file are all right codes what do you need.

You don't need exactly code there, you need search and use self... is the bet option for you for future.

Welcome