13

I have following code to filter out rows on a column that is null and it is working

->addFieldToFilter(
            'ep_image',
            ['null' => true]
       )

and I have another code to filter out rows on a column that is not null which is not working

->addFieldToFilter(
            'ep_image',
            ['notnull' => true]
       )

Can anyone help me out on how to filter not null values?

Also tried array('notnull' => true)and array('null' => false), but none working.

2 Answers 2

28

You can try this

->addFieldToFilter(
            'ep_image',
            ['neq' => 'NULL']
       )
1
  • 2
    Thanks @userpk, that worked!!! Above code mentioned by me also worked, the issue was due to same variable being used by two different code.
    – Nausif
    Commented Feb 10, 2017 at 9:16
2

The followings work for me correctly:

//IS NULL

->addFieldToFilter(
 'ep_image',
 array('null' => true)

//IS NOT NULL

->addFieldToFilter(
 'ep_image',
 array('notnull' => true)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.