VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: sandomatyas on March 28, 2023, 10:19:08 AM

Title: VM4 doesn't remember the filter
Post by: sandomatyas on March 28, 2023, 10:19:08 AM
Test case:

Here is a video about it: https://www.dropbox.com/s/uaz13gx40ta9zn8/2023-03-28-10-15-07.mp4?dl=0
Title: Re: VM4 doesn't remember the filter
Post by: sandomatyas on October 03, 2023, 18:28:17 PM
The topic is >6 months old, 4.2.4 was released, the issue is still there.
Title: Re: VM4 doesn't remember the filter
Post by: sandomatyas on December 11, 2023, 17:02:52 PM
Can others confirm this?
Title: Re: VM4 doesn't remember the filter
Post by: niosme on December 13, 2023, 11:07:16 AM
Yes this issue exists and occurs on every installation.
I can confirm and also i asked for it to be fixed and nothing yet.
Title: Re: VM4 doesn't remember the filter
Post by: BrownSystems on January 17, 2024, 23:37:26 PM
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.
Title: Re: VM4 doesn't remember the filter
Post by: BrownSystems on January 18, 2024, 00:01:39 AM
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!


Title: Re: VM4 doesn't remember the filter
Post by: 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
Title: Re: VM4 doesn't remember the filter
Post by: BrownSystems on January 18, 2024, 22:12:36 PM
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.