Skip to content

fix: re-check price for product whose indexed range exceeds the filter - #1283

Open
florianthomi wants to merge 1 commit into
PrestaShop:devfrom
florianthomi:fix/price-filter-bound-equality
Open

fix: re-check price for product whose indexed range exceeds the filter#1283
florianthomi wants to merge 1 commit into
PrestaShop:devfrom
florianthomi:fix/price-filter-bound-equality

Conversation

@florianthomi

Copy link
Copy Markdown

The SQL selects products with inclusive bounds (price_min <= max), while the straddle test used a strict comparison (price_min < max). A product whose indexed price_min lands exactly on the requested upper bound therefore escaped the re-check and stayed in the listing at its real price, outside the range. The mirror case exists on the lower bound.

The extra clause is unnecessary: a re-check is needed exactly when the indexed envelope is not fully contained in the requested range, since a contained envelope guarantees the real price is in range. Also drop the int casts, which truncated non-integer bounds before comparison.

Questions Answers
Description? A product whose indexed price_min lands exactly on the requested upper bound escapes the price re-check and stays in the listing at its real price, outside the range. The SQL selects with inclusive bounds while the straddle test uses a strict comparison.
Type? bug fix
BC breaks? no
Deprecations? no
Fixed ticket? Fixes #1282
How to test? See below.
Sponsor company iomedia

How to test

  1. PrestaShop 8.x, ps_facetedsearch enabled with a price filter on a category.
  2. Give the Customer group a discount (Customers > Groups) so products get a wide indexed range.
  3. Rebuild the price index (module configuration, or ps_facetedsearch-price-indexer.php).
  4. Pick a product, read its price_min in ps_layered_price_index, and browse the category as a guest with a price filter whose upper bound equals that exact value.

Before: the product is listed even though its real price is well above the bound. Any neighbouring bound excludes it correctly — only the one landing on price_min triggers it.

After: it is excluded, and it still shows up under the ranges that actually contain its price.

… filter

The SQL selects products with inclusive bounds (price_min <= max), while the
straddle test used a strict comparison (price_min < max). A product whose
indexed price_min lands exactly on the requested upper bound therefore escaped
the re-check and stayed in the listing at its real price, outside the range.
The mirror case exists on the lower bound.

The extra clause is unnecessary: a re-check is needed exactly when the indexed
envelope is not fully contained in the requested range, since a contained
envelope guarantees the real price is in range. Also drop the int casts, which
truncated non-integer bounds before comparison.
@ps-jarvis

Copy link
Copy Markdown

Hello @florianthomi!

This is your first pull request on ps_facetedsearch repository of the PrestaShop project.

Thank you, and welcome to this Open Source community!

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.

Price filter: products escape the price re-check when their indexed price_min equals the upper bound

2 participants