-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Description
This issue is automatically created based on existing pull request: #40358: Fixed catalog rule price processing when only website-scoped prices are used.
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:
- Removal of Unnecessary Join: The explicit
JOINto the default price table (pp_defaultwithstore_id = 0) has been removed from the product selection query. This join was causing issues when the default price entries were absent. - Default Value Handling: The logic for the
default_pricecolumn is updated to use SQL'sCOALESCEorIFNULLequivalent to return0if 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)
- Fixes magento/magento2#<issue_number>
...
Manual testing scenarios (*)
- 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 = 0in thecatalog_product_entity_decimaltable.
- 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.
- Attempt to run a full catalog rule reindex:
- 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)
Metadata
Metadata
Assignees
Labels
Type
Projects
Status