Index product prices for every active shop country - #1261
Open
boo-code wants to merge 1 commit into
Open
Conversation
The price index (layered_price_index) was only populated for the countries that have a specific tax rule for the product (when "use tax for filtering" is on). The price sort joins that table with an INNER JOIN on id_country = the customer's country, so customers from a country without such a tax rule got an empty product list when sorting by price, while every other sort worked. Index every active shop country instead: countries without a specific tax rule for the product are indexed untaxed (0% rate), exactly like already happens for products that have no tax rule at all. The taxed countries keep their computed prices unchanged.
|
Hello @boo-code! This is your first pull request on ps_facetedsearch repository of the PrestaShop project. Thank you, and welcome to this Open Source community! |
kpodemski
approved these changes
Jul 6, 2026
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.
indexProductPrices()computes prices for all countries but only insertslayered_price_indexrows for the countries returned by the tax-rule query ($taxRatesByCountry) whenPS_LAYERED_FILTER_PRICE_USETAXis on. The price sort joins that table withINNER JOIN ... AND psi.id_country = <customer country>, so a customer from a country that was never indexed matches no rows and gets an empty list. The fix indexes every active shop country: countries without a specific tax rule are indexed untaxed (0% rate) — exactly what the module already does for products that have no tax rule at all. Taxed countries keep their computed prices unchanged.price_min=22.944, price_max=28.680) and adds the US row untaxed (price_min=19.120, price_max=23.900), and the price-sortINNER JOINonid_country=21now returns the product instead of nothing.Verification (default shop,
PS_LAYERED_FILTER_PRICE_USETAXon):indexProductPrices()is a private method on the module class (no unit-test harness covers it, like the rest of the indexer), so this was verified by re-indexing against a real database and diffing the rows, confirming the taxed-country prices are byte-identical. The index now covers active shop countries, with the same row shape the no-tax-rule path already produces.