- Posts: 193
- Thank you received: 76
Product filters don't work with falsy values
11 years 10 months ago #179057
by korzo
Product filters don't work with falsy values was created by korzo
-- HikaShop version -- : 2.3.4
-- Joomla version -- : 3.3.6
Product filters with falsy values are ignored.
Problem is in file \plugins\hikashop\massaction_product\massaction_product.php on line 60:
Replacing
with
fixed the problem, but I'm not sure about all consequences.
Here is screenshot with test:
www.uploady.com/#!/download/x3Ez8neAvx8/fuY5C_AQ7ERf280G
-- Joomla version -- : 3.3.6
Product filters with falsy values are ignored.
Problem is in file \plugins\hikashop\massaction_product\massaction_product.php on line 60:
Code:
if(!empty($filter['value']) || (empty($filter['value']) && in_array($filter['operator'],array('IS NULL','IS NOT NULL')))){
Replacing
Code:
!empty($filter['value'])
Code:
isset($filter['value'])
Here is screenshot with test:
www.uploady.com/#!/download/x3Ez8neAvx8/fuY5C_AQ7ERf280G
Please Log in or Create an account to join the conversation.
11 years 10 months ago #179260
by Xavier
Replied by Xavier on topic Product filters don't work with falsy values
Hi,
Could you try that instead:
Could you try that instead:
Code:
if((!empty($filter['value']) || $filter['value'] == '0' ) || (empty($filter['value']) && in_array($filter['operator'],array('IS NULL','IS NOT NULL')))){
Please Log in or Create an account to join the conversation.
11 years 10 months ago #179361
by korzo
Replied by korzo on topic Product filters don't work with falsy values
This solve the issue for 0 but not for empty string ''.
Please Log in or Create an account to join the conversation.
11 years 10 months ago #179397
by Xavier
Replied by Xavier on topic Product filters don't work with falsy values
Hi,
In which case do you want to let the field empty ?
In most of the filters, we can't allow an empty field, or you have to select "IS NULL" in the dropdown before that field.
In which case do you want to let the field empty ?
In most of the filters, we can't allow an empty field, or you have to select "IS NULL" in the dropdown before that field.
Please Log in or Create an account to join the conversation.
11 years 10 months ago #179474
by korzo
Replied by korzo on topic Product filters don't work with falsy values
IS NULL doesn't help because Hikashop use empty string when data are not provided.
I need it when I want to search for products not having filled alias, meta, title... etc.
I need it when I want to search for products not having filled alias, meta, title... etc.
Please Log in or Create an account to join the conversation.
11 years 10 months ago #179478
by Xavier
Replied by Xavier on topic Product filters don't work with falsy values
You can use a filter like:
field_name = "NOT REGEXP" "[a-zA-Z]"
Which means that it will show all the product where the field "field_name" doesn't have any character.
field_name = "NOT REGEXP" "[a-zA-Z]"
Which means that it will show all the product where the field "field_name" doesn't have any character.
Please Log in or Create an account to join the conversation.
11 years 10 months ago #179561
by korzo
Replied by korzo on topic Product filters don't work with falsy values
I'm fine to use REGEXP ^\s*$ , but it's hard to persuade clients to dive in Regex.
My only concern is that user is allowed to save empty field and gets misleading results.
My only concern is that user is allowed to save empty field and gets misleading results.
Please Log in or Create an account to join the conversation.
11 years 10 months ago #179570
by Xavier
Replied by Xavier on topic Product filters don't work with falsy values
Hi,
You can potentially use your code, but I think that in some situations that can cause errors, not sure (there is a lot of possibilities).
Thanks to report us if any problems are met, if not we will do more tests with your suggested code and potentially use it in a future release if everything is ok.
You can potentially use your code, but I think that in some situations that can cause errors, not sure (there is a lot of possibilities).
Thanks to report us if any problems are met, if not we will do more tests with your suggested code and potentially use it in a future release if everything is ok.
Please Log in or Create an account to join the conversation.
Time to create page: 0.307 seconds