Search code examples
magentomagento2

Magento 2 - Configurable product's min_price and max_price are 0 and can't be changed?


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


Solution

  • 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.