News:

Support the VirtueMart project and become a member

Main Menu

VM4 doesn't remember the filter

Started by sandomatyas, March 28, 2023, 10:19:08 AM

Previous topic - Next topic

sandomatyas

Test case:

  • Go to VirtueMart -> Products
  • Search for a product name: it'll filter the products
  • Click "products" in the left menu
  • VM keeps the keyword input filled, but the product list is not filtered

Here is a video about it: https://www.dropbox.com/s/uaz13gx40ta9zn8/2023-03-28-10-15-07.mp4?dl=0

sandomatyas

The topic is >6 months old, 4.2.4 was released, the issue is still there.

sandomatyas


niosme

Yes this issue exists and occurs on every installation.
I can confirm and also i asked for it to be fixed and nothing yet.
Fullstack Developer and Joomla Expert

BrownSystems

I am also seeing this issue. In addition to the filter not being applied when clicking "products" in the menu, this also occurs when toggling "on featured" and likely other things. This is a major issue for my client as they frequently change "On featured" and need to have the list filtered as they do. As it is now the search has to be repeated after each change to "On featured" which makes it a real time suck.

I have spent a significant amount of time trying to debug this but haven't gotten anywhere. I'll let you all know if I find a fix. Any direction on where to look for the problem would be appreciated.

BrownSystems

Found the problem. In "/administrator/components/com_virtuemart/models/product.php" in "function populateState ()" line 273.

Change:

$this->keyword = vRequest::getString('filter_product','');

To:

$this->keyword = $this->filter_product;


I don't know why this fixed it but I found my way to populateState() and compared it to the VM 3 version and found this line was different.

Hope this helps someone else save a few hours!



Alexb65

The correct line should be:

$this->keyword = vRequest::getString('filter_product',$this->filter_product);

that means that if there is not a request , then get the filter.

This is from the latest svn and should fix the behaviour

I think your fix may be wrong since it ignores the request completely

BrownSystems

Quote from: Alexb65 on January 18, 2024, 09:49:39 AM
The correct line should be:

$this->keyword = vRequest::getString('filter_product',$this->filter_product);

that means that if there is not a request , then get the filter.

This is from the latest svn and should fix the behaviour

I think your fix may be wrong since it ignores the request completely

Thanks! My fix did seem to work just fine, but so does this. It's not clear to me when (if ever) the request variable would be needed in the product model but I've opted to use your suggestion just in case. Maybe there is some action I am not aware of that needs the request variable or perhaps it's for something in the future.