Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Price filter gets negative price #3300

Open
ioweb-gr opened this issue Jun 19, 2024 · 16 comments
Open

Price filter gets negative price #3300

ioweb-gr opened this issue Jun 19, 2024 · 16 comments
Assignees

Comments

@ioweb-gr
Copy link

Every now and then in some categories, the price slider starts to show negative prices in the lowest margin. The upper boundary is correct.

Preconditions

Magento Version : 2.4.6-p4 CE

ElasticSuite Version :2.11.5.1

Environment : Production mode

Third party modules :

Steps to reproduce

  1. I'm not sure how to reproduce this but I keep getting negative prices in the price filter.

Expected result

  1. The price filter starts from the minimum price in the product listing.

Actual result

image

@vahonc
Copy link
Collaborator

vahonc commented Jun 19, 2024

Hello @ioweb-gr,

It's more likely that this problem is related to your environment and its settings. I'm not sure that we can reproduce it without fully understanding how everything is configured.

Are you sure that there are no established discounts or catalog price rules, in other words, something that could affect on a negative price?

BR,
Vadym

@ioweb-gr
Copy link
Author

Hi @vahonc We don't actualy use any catalog rules

image

As far as the filter is concerned it's behaving really weird

Check what happens as I change the price slider

firefox_PqV9DxR5fW.mp4

I'm not really sure where to start to provide the require info.

Any ideas what I should check and provide the necessary info?

@vahonc
Copy link
Collaborator

vahonc commented Jun 19, 2024

@ioweb-gr,

What is the status of this setting?

Screenshot from 2024-06-19 15-17-03

What about your fronted theme? Is there fully compatibility (based on) with default Luma theme? If it possible try to switch to Luma theme.

Have you checked the price of your products or discount rules?

BR,
Vadym

@ioweb-gr
Copy link
Author

It's set to Yes

image

I've sampled a lot of them, and they appear proper. Moreover, when I sort them by price Ascending, no product appears with a negative price on the catalog and everything is purchaseable properly at the displayed price.

@romainruaud
Copy link
Collaborator

can you enable the debug mode of Elasticsuite and give us the query it's generating ?

if you can replay this query via cerebro (if you're familiar with it), I'd like to be able to show the results as well.

Regards

@ioweb-gr
Copy link
Author

I'm not familiar with cerebro. I'll try to check the debug mode when there's a bit less traffic

@ioweb-gr
Copy link
Author

ioweb-gr commented Jun 19, 2024

What about your fronted theme? Is there fully compatibility (based on) with default Luma theme? If it possible try to switch to Luma theme.

Forgot to answer this is the LUMA theme, we just changed styles

Copy link

This issue was waiting update from the author for too long. Without any update, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now. Please don't hesitate to comment on the bug if you have any more information for us; we will reopen it right away! Thanks for your contribution.

@ioweb-gr
Copy link
Author

Just an update here I think we're suffering from this

magento/magento2#24953
magento/magento2#15609

@github-actions github-actions bot reopened this Aug 27, 2024
@vahonc
Copy link
Collaborator

vahonc commented Aug 27, 2024

@ioweb-gr,

Are you able to reproduce this issue without (disabled) ElasticSuite module?

can you enable the debug mode of Elasticsuite and give us the query it's generating ?

Have you found something that can help us to understand your problem?

BR,
Vadym

@ioweb-gr
Copy link
Author

Hi

Yes actually I tested further and the negative prices appear after removing elastic suite as well so it's not the reason the indexes are created wrong but the core itself.

What I haven't been able to determine because I cannot remove it for a prolonged period of time is whether the prices in the configurable products are created because the elastic suite is enabled or not

The culprit however is that configurable products suddenly have prices stored in the db which create a problem in the indexer.

@rikwillems
Copy link

@romainruaud if we can agree that Magento prices never go below 0 we could do the following to fix the issue in the price filter.

File: src/module-elasticsuite-catalog/Block/Navigation/Renderer/PriceSlider.php line 77

-         $minValue = $this->getFilter()->getMinValue();
+        $minValue = max(0, $this->getFilter()->getMinValue());

@romainruaud
Copy link
Collaborator

@rikwillems indeed but this would not really solve the root cause of the issue, which I'd like to know : if we see negative price, it means at some point they get indexed in Elasticsearch, but also in the Magento price index table, which is very strange.

Regards

@rikwillems
Copy link

@romainruaud that is true. But as the related Magento tickets are quite old already I went down this road. For my project I have this as a patch, but for sure good to track the origin issue.

@ioweb-gr
Copy link
Author

ioweb-gr commented Oct 24, 2024

@rikwillems This doesn't help either because it will give you invalid range.

Let's say that normally products start at 50$ price and max is 120$

If the filter which was negative now shows 0 as the minimum, the user can set the price filter to minimum 0 and max 40 for example and he'd see 0 products.

It will still be a mistake as he should see the lowest boundary properly

We still haven't been able to identify the root cause why negative prices are being created

@romainruaud
Copy link
Collaborator

In any cases, if you have a negative price in catalog_product_index_price table, you're f**ed, because we'll just basically assume Magento computed the price properly and we'll index this in ES "as is".

So if this is the case, it's not an Elasticsuite related bug, but a Magento one, and we'll have no way to fix this here :(

regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants