Skip to content

Display correct count in price slider if range ‚from value‘ = ‚to value‘#1125

Open
annakoehler wants to merge 1 commit into
Smile-SA:masterfrom
annakoehler:priceslider_fix
Open

Display correct count in price slider if range ‚from value‘ = ‚to value‘#1125
annakoehler wants to merge 1 commit into
Smile-SA:masterfrom
annakoehler:priceslider_fix

Conversation

@annakoehler

Copy link
Copy Markdown

f.e. we have products in shop with price 100$. If we make in price slider "from value" = "to value", we got "No products in the selected range." message. Also if we open direct url https://some_shop/some_url?price=100-100 we didn't see the products with price 100$

@annakoehler

Copy link
Copy Markdown
Author

this is also related to the fix b647b03 and issue #381

@annakoehler

Copy link
Copy Markdown
Author

we had the problem not with price, but with other attribute. I saw you did changes for price and you have an step -0,01, but it doesn't work if you have no decimal numbers

@romainruaud romainruaud force-pushed the master branch 2 times, most recently from 28eb80b to 3cbc361 Compare July 31, 2020 12:58
@rbayet

rbayet commented Nov 30, 2021

Copy link
Copy Markdown
Collaborator

While the issue does exist when min = max in the slider, changing the behavior of the filter would lead to other problems, because the slider is built around an histogram which takes the floor() of a price.
So, considering you have in the middle of your slider four products with actual prices 68.0, 68.30, 69.0 and 69.30, the corresponding histogram slots will be :

  • 68 = 2
  • 69 = 2

At the moment, if you put min on 68 and max on 69, the number of available products will be displayed as 2 (because of the lt).
And the resulting page, on a price=68-69 will also display 2 products because of the (lt).

Now, if we adopt your changes, and if you put min on 68 and max on 69, the number of available products displayed will be 4 (because of the lte).
But on the resulting page, you will only see 3 products, because ['gt' => 68, 'lte' => 69] does not include 69.30.

@rbayet

rbayet commented Nov 30, 2021

Copy link
Copy Markdown
Collaborator

Not closing this PR right now, but the correct approach would be to prevent the from and to value to be equal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants