News:

Support the VirtueMart project and become a member

Main Menu

Show product images in Joomla search component

Started by Trimud, June 29, 2019, 23:05:04 PM

Previous topic - Next topic

Trimud

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

Yo have to modify the plugin, if you want display the thumb. No setting exist to display image

Trimud

Thanks, I'm aware of that, but what this modification should be?

Studio 42

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

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; ?>

EIF

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?

marvays

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.

pinochico

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
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products