Skip to content

Index product prices for every active shop country - #1261

Open
boo-code wants to merge 1 commit into
PrestaShop:devfrom
boo-code:fix/price-index-all-countries-1206
Open

Index product prices for every active shop country#1261
boo-code wants to merge 1 commit into
PrestaShop:devfrom
boo-code:fix/price-index-all-countries-1206

Conversation

@boo-code

Copy link
Copy Markdown
Contributor
Questions Answers
Description? When a customer's country has no specific tax rule for a product, sorting search/listing results by price returned 0 products for that customer, while every other sort worked. Root cause: indexProductPrices() computes prices for all countries but only inserts layered_price_index rows for the countries returned by the tax-rule query ($taxRatesByCountry) when PS_LAYERED_FILTER_PRICE_USETAX is on. The price sort joins that table with INNER 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.
Type? bug fix
BC breaks? no
Deprecations? no
Fixed ticket? Fixes #1206.
How to test? On a shop with at least two active countries where products have a tax rule for only one of them (e.g. FR), log in / set the context to the other country (e.g. US), open a listing and sort by price — before, the list is empty; after re-indexing prices, it shows the products. Verified on the default shop (active countries FR=8, US=21; products taxed for FR only): re-indexing product 1 keeps FR identical (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-sort INNER JOIN on id_country=21 now returns the product instead of nothing.
Sponsor company

Verification (default shop, PS_LAYERED_FILTER_PRICE_USETAX on):

before:  layered_price_index for product 1 -> only id_country=8 (FR): 22.944 / 28.680
         price sort for US (id_country=21)  -> 0 products

after:   id_country=8  (FR): 22.944 / 28.680   (unchanged)
         id_country=21 (US): 19.120 / 23.900   (untaxed, newly indexed)
         price sort for US (id_country=21)  -> returns the product

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.

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.
@ps-jarvis

Copy link
Copy Markdown

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!

@github-project-automation github-project-automation Bot moved this to Ready for review in PR Dashboard Jun 27, 2026
@ps-jarvis ps-jarvis added the Waiting for QA Status: Action required, Waiting for test feedback label Jul 6, 2026
@ps-jarvis ps-jarvis moved this from Ready for review to To be tested in PR Dashboard Jul 6, 2026
@kpodemski kpodemski added the Waiting for QA by Community Status: Action required, Waiting for test feedback by Community label Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Waiting for QA by Community Status: Action required, Waiting for test feedback by Community Waiting for QA Status: Action required, Waiting for test feedback

Projects

Status: To be tested

Development

Successfully merging this pull request may close these issues.

[BUG] No product at all for foreign countries when order by price

3 participants