Skip to content

Conversation

@mtytula
Copy link

@mtytula mtytula commented Dec 11, 2025

Description (*)

This Pull Request resolves an issue in the SQL query generated by Model/Indexer/RuleProductsSelectBuilder.php during catalog price rule indexing. The issue specifically occurs in environments where product prices are managed exclusively at the Website scope, meaning no price entries exist for store_id = 0 (Global/Default Store View) in the database.

The changes include:

  1. Removal of Unnecessary Join: The explicit JOIN to the default price table (pp_default with store_id = 0) has been removed from the product selection query. This join was causing issues when the default price entries were absent.
  2. Default Value Handling: The logic for the default_price column is updated to use SQL's COALESCE or IFNULL equivalent to return 0 if the website-specific price ($tableAlias.value) is not found. This prevents SQL errors related to missing joined records.

This ensures the price rule indexing mechanism correctly handles scenarios where price attribute scope is set to "Website" and the global default price is non-existent.

Related Pull Requests

...

Fixed Issues (if relevant)

  1. Fixes magento/magento2#<issue_number>
    ...

Manual testing scenarios (*)

  1. Data Preparation:
    • Ensure the 'Price' attribute scope is set to "Website".
    • Create a new product and set its price only at the Website scope (e.g., $10.00 for Website A).
    • Verify that no price entry exists for this product with store_id = 0 in the catalog_product_entity_decimal table.
  2. Verify Issue Reproduction (Before Fix):
    • Attempt to run a full catalog rule reindex: bin/magento indexer:reindex catalogrule_rule.
    • Expected Result: Indexing fails or produces incorrect data due to the missing join result.
  3. Verify Fix:
    • Apply the changes from this PR.
    • Run the catalog rule price reindex again: bin/magento indexer:reindex catalogrule_rule.
    • Expected Result: Indexing completes successfully without errors.

Questions or comments

Given the price attribute scope is "Website", the change sets default_price to 0 when no website-specific price is found. Please confirm if setting this value to 0 (instead of attempting to fetch a Global/Default Store value) is acceptable within the indexing context.

Contribution checklist (*)

 - [x] Pull request has a meaningful description of its purpose
 - [x] All commits are accompanied by meaningful commit messages
 - [ ] All new or changed code is covered with unit/integration tests (if applicable)
 - [ ] README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an update
 - [x] All automated tests passed successfully (all builds are green)

@m2-assistant
Copy link

m2-assistant bot commented Dec 11, 2025

Hi @mtytula. 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.

@mtytula mtytula closed this Dec 11, 2025
@mtytula mtytula reopened this Dec 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant