fix: re-check price for product whose indexed range exceeds the filter - #1283
Open
florianthomi wants to merge 1 commit into
Open
fix: re-check price for product whose indexed range exceeds the filter#1283florianthomi wants to merge 1 commit into
florianthomi wants to merge 1 commit into
Conversation
… 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.
|
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! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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.
price_minlands 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.How to test
ps_facetedsearchenabled with a price filter on a category.ps_facetedsearch-price-indexer.php).price_mininps_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_mintriggers it.After: it is excluded, and it still shows up under the ranges that actually contain its price.