News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Search no longer working

Started by p.barg, January 23, 2025, 10:05:04 AM

Previous topic - Next topic

p.barg

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

jflash


Dud3

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...

p.barg

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

carlos88

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.

Jumbo!

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);
}

jflash

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. :)

p.barg

Thanks Jumbo for sharing this fix - works fine  :)

Jumbo!

Quote from: p.barg on February 04, 2025, 10:09:37 AMThanks Jumbo for sharing this fix - works fine  :)

You are welcome. 😊

dennisg

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.

Jumbo!

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?

dennisg

Yes, just bought the Golden license and various bugs are now fixed.

Thanks!

Jumbo!

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. 👍