Skip to main content

Product filters don't work with falsy values

More
11 years 10 months ago #179057 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:
Code:
if(!empty($filter['value']) || (empty($filter['value']) && in_array($filter['operator'],array('IS NULL','IS NOT NULL')))){

Replacing
Code:
!empty($filter['value'])
with
Code:
isset($filter['value'])
fixed the problem, but I'm not sure about all consequences.

Here is screenshot with test:
www.uploady.com/#!/download/x3Ez8neAvx8/fuY5C_AQ7ERf280G

Please Log in or Create an account to join the conversation.

More
11 years 10 months ago #179260 by Xavier
Hi,

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.

More
11 years 10 months ago #179361 by korzo
This solve the issue for 0 but not for empty string ''.

Please Log in or Create an account to join the conversation.

More
11 years 10 months ago #179397 by Xavier
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.

Please Log in or Create an account to join the conversation.

More
11 years 10 months ago #179474 by korzo
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.

Please Log in or Create an account to join the conversation.

More
11 years 10 months ago #179478 by Xavier
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.

Please Log in or Create an account to join the conversation.

More
11 years 10 months ago #179561 by korzo
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.

Please Log in or Create an account to join the conversation.

More
11 years 10 months ago #179570 by Xavier
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.

Please Log in or Create an account to join the conversation.

Time to create page: 0.307 seconds
Powered by Kunena Forum