Jump to content

Blocklayered search - price not filtering correctly


Tomas Contos

Recommended Posts

Hi,

 

I am using PrestaShop 1.6.1.23

I found price filter is not outputting correctly filtered products. Is this common issue and is there any solution for this ?
For example

I have product with price 10.49 and even min filter set to 10.99 is showing this product.  Min filter set to 11 will not display product.

Another strange example, product cost 10.51 and even min filter set to 11.99 is displaying this product. Min filter set to 12.00 will hide this product.

Any solution or clue where to search in order to fix this issue ?

 

Thank you

Link to comment
Share on other sites

  • Tomas Contos changed the title to Blocklayered search - price not filtering correctly

When I look into table ps_layered_price_index I found price_min and price_max as INT. As well in whole process it is rounding these two values.

 

Do I understand corectly that price_min represents price without tax and price_max represents price with tax ?

Link to comment
Share on other sites

Yes it is rounding in module blocklayered v2.2.1 . I applied below changes and all start working properly.

Can somebody tell me which function is calculation min and max for price filter rendered on shop pages ? At the moment price indexing table PREFIX_layered_price_index has price_min and price_max set as INT. You need to change these into DECIMAL(10, 2)

Fix applied to get it works - amend file in modules/blocklayered/blocklayered.php

Find all occurences of below variables in methods and change it. Change it the way values are not parsed to int.

- (int)$filter_value[1]  => $filter_value[1]
- (int)$filter_value[0] => $filter_value[0]

In same module changes in file blocklayered-price-indexer.php

- echo BlockLayered::fullPricesIndexProcess((int)Tools::getValue('cursor'), (int)Tools::getValue('ajax'), true); => zmenene na echo BlockLayered::fullPricesIndexProcess(Tools::getValue('cursor'), Tools::getValue('ajax'), true);
 - echo BlockLayered::pricesIndexProcess((int)Tools::getValue('cursor'), (int)Tools::getValue('ajax')); => zmenene na echo BlockLayered::pricesIndexProcess(Tools::getValue('cursor'), Tools::getValue('ajax'));

Now price filter is filtering out correctly /taking decimal price as well/ 

Now I have to find where is price filter min and max taken from for price line filter in shop on left side. At the moment it take min price to be included in filter min price of one of lowest price products in database without tax and rounded to int. 
Max price for filter is max price of dearest product with tax rounded to int /in both cases it is rounded down/

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...