Skip to content

Conversation

@maxbucknell
Copy link
Contributor

Description

It is not possible to filter an EAV collection by an attribute being null.

Fixed Issues (if relevant)

Also addresses:

Manual testing scenarios

As addressed by the integration test, load a product collection and try to addAttributeToFilter and select an attribute to be null. This is a correct usage of the API, and the where clause is generated correctly, as ... WHERE ((at_special_price.value IS NULL)).

However, without this diff, the join is an INNER JOIN, which automatically excludes null values.

Discussion

I have chosen to add a little complexity here, by checking for a null comparison and only then selecting a LEFT JOIN. It would work fine to use a LEFT JOIN for this all the time, but I suspect that INNER JOIN was chosen for a reason, perhaps performance. I decided it was best to respect this decision and change as little as possible.

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@magento-cicd2
Copy link
Contributor

magento-cicd2 commented Mar 25, 2018

CLA assistant check
All committers have signed the CLA.

@magento-engcom-team
Copy link
Contributor

Hi @maxbucknell. Thank you for your contribution.
Changes from your Pull Request will be available with the upcoming 2.3.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants