Fixed catalog rule price processing when only website-scoped prices are used. #40358
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description (*)
This Pull Request resolves an issue in the SQL query generated by
Model/Indexer/RuleProductsSelectBuilder.phpduring 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 forstore_id = 0(Global/Default Store View) in the database.The changes include:
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_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)
...
Manual testing scenarios (*)
store_id = 0in thecatalog_product_entity_decimaltable.bin/magento indexer:reindex catalogrule_rule.bin/magento indexer:reindex catalogrule_rule.Questions or comments
Given the
priceattribute scope is "Website", the change setsdefault_priceto0when no website-specific price is found. Please confirm if setting this value to0(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)