0
votes

Recently, I've imported about 40.000 products through CSV to a Magento 2 staging environment (Community 2.4.1). Many of these products are configurable products (e.g. a table) with child products (red table, green table, ...) attached to it.

After the import, I noticed my price ordering and filtering is not working correctly. I figured out that column min_price and max_price of table catalog_product_index_price are '0' for all configurable products. Unlike when manually creating configurable products, Magento apparently isn't filling these columns during CSV imports. Not sure if a bug, or my mistake.

I need to fix min_price and max_price for all configurable products in order for the filters and sorting to work. I've tried updating the columns directly in catalog_product_index_price, but no result (just changes back to 0 after reindexing). I'm still digging into Magento's database structure, but can't seem to find any other place where min_price and max_price are stored though.

Am I missing something?

Example of a configurable product

1
I'm still testing some, but I think I'm close I do not have stock quantity management enabled because all products are custom made on each order. Apparently Magento 2's price indexing does not set min_price nor max_price if a configurable product's simple products do not have a stock quantity set. - Jason
When you say that your price and filtering wasn't working correctly what happened? Magento uses the price of the child items, to determine the price of the product, this is why the price is not copied. - Rob
You're correct. Magento indeed uses the price of child products to determine the price to display for a configurable product ("starting from $100). However, M2's price filtering feature doesn't directly call the child products to determine price filter ranges. Instead, it uses the "min_price" and "max_price" of a configurable product. Those are set during indexing, using its child products. My problem was the fact that M2 sets min/max_price to ZERO in case there is no stock set for the simple products. Result of that was the fact that I saw just 1 price filter range: "$ 0.00 - $0.99". - Jason
What search engine do you use, MySQL or Elastic? - Rob
I'm using Elastic. - Jason

1 Answers

0
votes

I finally found it.

Even though my store does not have a stock, I had to:

  • Set the Qty of all products to > 0.
  • Set all products to "is_on_stock".

Apparently there's a bug (at least, I think it's a bug) in M2 that is causing the indexer to set a Configurable Product's min_price and max_price to zero in case its Simple Products do not have a Qty or is_on_stock set.

Perhaps there's a reason behind that, but to me, it makes absolutely no sense.