VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: p.barg on January 23, 2025, 10:05:04 AM

Title: Search no longer working
Post by: p.barg on January 23, 2025, 10:05:04 AM
Hello,

I'm about to migrate a site from J3/VM3 to J5/VM4.
Most things are going fine so far, but I noticed that the Virtuemart search stopped working...
No matter what I enter, the result is empty. Only if I leave the input field empty, all products are
listed.

I'm using Joomla!5.2.3 and Virtuemart4.4.4, PHP 8.2

Any ideas?

Thanks, Petra
Title: Re: Search no longer working
Post by: jflash on January 23, 2025, 11:09:31 AM
There is same: https://forum.virtuemart.net/index.php?topic=152229.0 but no answers yet.
Title: Re: Search no longer working
Post by: Dud3 on January 24, 2025, 14:11:29 PM
It has to do with the search settings of Virtuemart and the menu entry.

If a search is active Virtuemart uses the setting "Show search" in the main-menu-item tab "Virtuemart subordinated category settings".
This has to be enabled or set to global, then the setting of the Virtuemart main configuration is used.

Only if this is enabled, the search query will be triggered (or if productModel->searchcustoms is filled).
Had to debug this too to find the issue...
Title: Re: Search no longer working
Post by: p.barg on January 27, 2025, 10:15:56 AM
Thanks for your answer, Dud3.

Unfortunately, setting the search options in the menu item as you suggested, didn't change the
result in my case. It's still always empty...

Thanks, anyway,
Petra
Title: Re: Search no longer working
Post by: carlos88 on January 30, 2025, 17:31:08 PM
I'm testing the update to VM 4.4.4 and I'm experiencing the same issue. 

The search actually works fine until I edit a product. After that, the specific product can no longer be found when searching from the frontend. 

Any idea when the next VM version will be released for those of us with a paid membership? 

Carlos.
Title: Re: Search no longer working
Post by: Jumbo! on February 03, 2025, 15:56:17 PM
There is a bug in VirtueMart 4.4.4, which will be fixed in the next update. In the meantime, you can make the following changes to your site to resolve the issue.

Open - components/com_virtuemart/views/category/view.html.php

Find the following codes between lines 248 to 257:

if(!empty($this->showsearch) and !empty($this->keyword) or !empty($this->productModel->searchcustoms)) {
vmdebug('Lets load the search',$this->keyword,$this->productModel->searchcustoms);
// Load the products in the given category
$ids = $this->productModel->sortSearchListQuery (TRUE, $this->categoryId);
VirtueMartModelProduct::$_alreadyLoadedIds = array_merge(VirtueMartModelProduct::$_alreadyLoadedIds,$ids);
$this->vmPagination = $this->productModel->getPagination($this->perRow);
$this->orderByList = $this->productModel->getOrderByList($this->categoryId);
$this->products['products'] = $this->productModel->getProducts ($ids);
$this->productModel->addImages($this->products['products'], $imgAmount );
}
Replace the above by:

if (!empty($this->keyword) or !empty($this->productModel->searchcustoms)) {
vmdebug('Lets load the search', $this->keyword, $this->productModel->searchcustoms);
// Load the products in the given category
$ids = $this->productModel->sortSearchListQuery(true, $this->categoryId);

VirtueMartModelProduct::$_alreadyLoadedIds = array_merge(VirtueMartModelProduct::$_alreadyLoadedIds, $ids);

$this->vmPagination         = $this->productModel->getPagination($this->perRow);
$this->orderByList          = $this->productModel->getOrderByList($this->categoryId);
$this->products['products'] = $this->productModel->getProducts($ids);

$this->productModel->addImages($this->products['products'], $imgAmount);
}
Title: Re: Search no longer working
Post by: jflash on February 03, 2025, 18:23:36 PM
Thanks, good to know that the issue is resolved! When I discovered that the search wasn't working, I reverted the website from a backup. Once the new version is released, I'll give it another try. :)
Title: Re: Search no longer working
Post by: p.barg on February 04, 2025, 10:09:37 AM
Thanks Jumbo for sharing this fix - works fine  :)
Title: Re: Search no longer working
Post by: Jumbo! on February 04, 2025, 16:54:02 PM
Quote from: p.barg on February 04, 2025, 10:09:37 AMThanks Jumbo for sharing this fix - works fine  :)

You are welcome. 😊
Title: Re: Search no longer working
Post by: dennisg on March 06, 2025, 08:51:16 AM
Hi Jumbo, applied your fix but I still get empty results in search. Any idea if something else could be causing this problem? Previous version used was VM 4.2.18.11050 which was working fine.
Title: Re: Search no longer working
Post by: Jumbo! on March 07, 2025, 22:31:22 PM
Quote from: dennisg on March 06, 2025, 08:51:16 AMHi Jumbo, applied your fix but I still get empty results in search. Any idea if something else could be causing this problem? Previous version used was VM 4.2.18.11050 which was working fine.

Have you tried VM 4.4.6?
Title: Re: Search no longer working
Post by: dennisg on March 08, 2025, 10:46:20 AM
Yes, just bought the Golden license and various bugs are now fixed.

Thanks!
Title: Re: Search no longer working
Post by: Jumbo! on March 10, 2025, 10:36:07 AM
Quote from: dennisg on March 08, 2025, 10:46:20 AMYes, just bought the Golden license and various bugs are now fixed.

Thanks!

Great. Thank you for the confirmation. 👍