4

We have a problem with our price filter. We are using magento 2.2.6 and Smile-SA/elasticsuite 2.6.x-dev.

When I go to a category and set a price range filter 0-0,99 I get results with a higher price. The URL looks like: /baelle/?price=0-1 Categories with filter example When I query the ElasticSearch manually for one of the given SKUs the price looks always as the following for all customer groups:

price: [
    {
        price: "0.0000",
        original_price: "79.9500",
        is_discount: true,
        customer_group_id: "0"
    }
],

In the backend the product is configured with a price of 79.95 and no advanced pricing. In the catalog__product_index_price table it's stored like this:catalog_products_index_price

But when I set special_price in the backend the price in ElasticSearch changes to the according special_price. Similar to the entries in catalog_product_index_price it looks now like this:catalog_product_index_price with special price

All of this happens to configurable and simple products alike and we have no idea where or what the problem could be.

Any ideas why the price filter is not working as expected?

Update

I figured out we have some products where the indexer is working as expected but for the majority it is not. \Catalog\Model\ResourceModel\Product\Indexer\Price\DefaultPrice::prepareFinalPriceDataForType() Is not beeing called either way.

I executed php bin/magento dev:tests:run unit to see if maybe an test for the indexer is failing but only one test failed and it has nothing to do with the indexer.

I tried to find a pattern which products are working as expected and which don't but I had no luck with it.

Update 2

I started to disable all third party modules. After disabling all, clearing all caches and executing bin/magento setup:di:compile there is still no difference.

Update 3

I have tried to run the dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Product/Price integrations tests in order to figure out some more details but the tests fail straight away with the following error:

Error in fixture: "dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple.php". Unable to save Stock Item

Could this error lead into a wrong index?

  • Not sure if it is a Magento core bug or ElasticSuite is assuming a behaviour that is not true for Magento – Alex Oct 19 '18 at 9:32
2

It definitely looks like the price indexer is not working properly. I've checked it on Magento 2.2.6 vanilla and final_price, min_price and max_price have the same value as the price column.

The moment I change the price in admin all the values are changed (indexer set to on save). Maybe some extension is messing the indexer?

Without access to the code is hard to say but I would suggest to start debugging from

\Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\DefaultPrice::prepareFinalPriceDataForType()

function - it is a function that prepares the final price data for certain product type. In this function you can find a call to getSelect() which generates an sql query for getting the data. Check if this function is called, maybe some extension is overriding it. If it's called check the data that the query gets. Good luck!

  • this function is not even called in my case i compared with a vanilla and it is called. Any idea to figure out what is overriding this method? – Daniel Oct 23 '18 at 7:12
  • i ran php bin/magento dev:tests:run unit in order to see if an indexer test fails but they all worked – Daniel Oct 23 '18 at 7:35
  • the question is, is this particular class overrided or maybe some other. You can search with you IDE for a phrase Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\DefaultPrice and check is there any reference of it in some 3rd party modules di.xml files. If no, you can check \Magento\Catalog\Model\Indexer\Product\Price\Action\Full::execute - this is the function that is runned when you launch price indexer from CLI. This function uses _defaultIndexerResource var which in vanilla is the defaultprice class. Check what class it uses. – Sebastian Oct 23 '18 at 7:52
  • And the last option, you can disable 3rd party modules and check when it starts to work ;) – Sebastian Oct 23 '18 at 7:52
  • I updated the question again. I did disabled all third party modules and still have the same issue that really confusing. – Daniel Oct 24 '18 at 15:50
1

The problem here was about the catalog_product_price index being built wrong. If a product has special_from_date set but no special_price set the indexer will set the final_price, min_price and max_price to 0.0000.
This behavior corrupts the prices for configurable products and the elasticsearch index alike.

To fix it make sure if no special_price is set there is not set a special_from_date either.
Or apply this commit as patch. Or update Magento to 2.2.8 or 3.0.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.