Skip to content

Fix: Index each product once per catalog price rule save, also on creation - #1375

Open
LameuleFR wants to merge 4 commits into
PrestaShop:devfrom
LameuleFR:fix/price-rule-hook-dedupe
Open

LameuleFR wants to merge 4 commits into
PrestaShop:devfrom
LameuleFR:fix/price-rule-hook-dedupe

Conversation

@LameuleFR

@LameuleFR LameuleFR commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor
Questions Answers
Description? Saving a catalog price rule indexes each affected product once, and creating one indexes them too. See below.
Type? bug fix
BC breaks? no
Deprecations? no
Fixed ticket? Related to #1372
How to test? See below.
Sponsor company

Depends on #1364 (only the last commit belongs to this PR).

On the catalog price rules page (the legacy one, used unless the catalog_price_rule feature flag is enabled), actionAdminSpecificPriceRuleControllerSaveAfter reindexed every row of getAffectedProducts(), before and after the save:

  • with attribute conditions, getAffectedProducts() returns one row per matching combination, so a product was indexed once per combination,
  • a product affected before and after an update was indexed twice,
  • a new rule was never indexed: the product list is only collected by actionObjectSpecificPriceRuleUpdateBefore, which doesn't fire on creation, and the hook returned early without it.

Each affected product is now indexed once, on creation too. A rule without conditions returns id_product 0, which is skipped as before: it affects the whole catalog and still needs a price index rebuild.

The Symfony page (catalog_price_rule feature flag on), rule deletion and rules affecting the whole catalog are handled in a follow-up.

On the bench rule of #1374 (category + color conditions, 120 products, 128 rows), an update ran indexProductPrices() 256 times, now 120.

How to test

  1. Create a catalog price rule with a category and an attribute condition: the price filter of that category shows the reduced prices without rebuilding the index.
  2. Edit it (change the reduction, then the category): the products of the old and of the new category are reindexed once each.
  3. tests/php/FacetedSearch/Hook/SpecificPriceTest.php passes.

getAffectedProducts() returns one row per combination with attribute
conditions, and products affected before and after an update were
indexed twice. A new rule was never indexed since no product list is
collected before its creation.
@github-project-automation github-project-automation Bot moved this to Ready for review in PR Dashboard Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Ready for review

Development

Successfully merging this pull request may close these issues.

2 participants