Skip to content

magento/magento2#32805: Fix catalog rule negative conditions for missing values - #41116

Open
swnsma wants to merge 2 commits into
magento:2.4-developfrom
swnsma:magento/magento2#32805
Open

magento/magento2#32805: Fix catalog rule negative conditions for missing values#41116
swnsma wants to merge 2 commits into
magento:2.4-developfrom
swnsma:magento/magento2#32805

Conversation

@swnsma

@swnsma swnsma commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Fixed Issues

  1. Fixes Catalog Price Rule with Condition Not / Is Not One Of / Does not Contain are not applied to products without a value - and there is no "undefined" condition  #32805

Manual testing scenarios

  1. Create a multiselect product attribute with Use for Promo Rule Conditions enabled.
  2. Create product A without a value for that attribute and product B with option X selected.
  3. Create a catalog price rule with condition: attribute does not contain / is not one of option X; apply and reindex.
  4. Verify product A receives the rule discount and product B does not.
  5. Change the condition to multiselect is undefined; verify only products without a value match.
  6. Create a catalog rule with Category is not [category C]; verify products outside C are discounted and products in C are not.

Questions or comments

Negative catalog price rule conditions (!=, !{}, !()) previously excluded products with no EAV row / empty value because SQL filters only saw rows that existed in the attribute tables, and PHP validation treated missing values as non-matching.

This change:

  • Builds negative EAV filters as “match positive set, then outer NOT IN” so missing values are included (EavAttributeCondition).
  • Treats null / empty / empty-array as matching for negative operators and for multiselect is undefined (<=>) in PHP validation.
  • Maps <=>is_null and reverses is_nullnotnull for FALSE combines (“is defined” without a separate operator).
  • Hardens Rule SQL builder negatives / <=> for Catalog Widget (and shared rule SQL).

Coverage: unit + integration (matching IDs, collection SQL path, rule price, widget, sales rule) + MFTF for category is not, multiselect does not contain, and multiselect is undefined.

Negative catalog price rule conditions (is not, does not contain, is not one of)
now match products with missing or empty attribute values. Multiselect gains
an "is undefined" operator; inverse "is defined" is expressed via a FALSE combine.
@m2-assistant

m2-assistant Bot commented Aug 13, 2026

Copy link
Copy Markdown

Hi @swnsma. Thank you for your contribution!
Here are some useful tips on how you can test your changes using Magento test environment.
❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names.

Allowed build names are:
  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here
ℹ️ Run only required test builds during development. Run all test builds before sending your pull request for review.


For more details, review the Code Contributions documentation.
Join Magento Community Engineering Slack and ask your questions in #github channel.

Drop apply-button click for multiselect condition values and open Actions
via the fieldset selector used by core catalog rule MFTFs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority: P3 May be fixed according to the position in the backlog. Progress: pending review

Projects

Status: Pending Review

2 participants