Can anyone explain why exactly a configurable product for which every virtual product’s quantity goes down to zero, and said product subsequently disappears from the store, won’t come back even if the quantities are brought back to >0 by hand and the status is specifically set to “in-stock”? This is related to Configurable product still out of stock even after child product is back in stock but there was no definitive answer to that one.
We’re doing POST requests to create new products and reconfigure existing ones. So essentially it goes like this:
- There’s a product with 3 sizes, sizes L and S are out of stock with quantity = 0, size XXL is in stock and quantity = 1.
- POST all virtual products, POST the main product
- Observe that the product appears in the store with sizes dropdown listing all three sizes (that’s strangeness #1 as only one size should be seen in the dropdown)
- POST a virtual product of size XXL with quantity = 0
- Observe that the product has disappeared from the store as expected
- POST the same virtual product with quantiy = 1 and is_in_stock = true
- Observe how those parameters have changed in admin accordingly and the product is marked now as “in stock”, also observe how the product hasn’t re-appeared in the storefront regardless of that
Worse yet, you can’t just delete those 4 products and re-POST them again, because they won’t appear. What you have to do is
- Delete the products
- Do a reindex
- POST the products again
Reindexing without deleting and re-POSTing changes nothing – the product still won’t appear.
Moreover, if you make an SQL dump of the state when the product shows up on the storefront, then make it go out of stock, clear the database and restore from that backup, the product still won’t appear, meaning the problem concerns not only the database data, but also Elasticsearch indexes, and fixing just one of those two doesn’t work.
Now can someone explain to me why that happens at all and if there’s a way to make the products re-appear after a POST request makes a product available again. I’ve tried disabling stock managing but that simply makes products always show regardless of their status, i.e. not what we need.
Also of note is the strange behavior of the sizes dropdown just after POSTing – normally if you have a product with all sizes in stock and start to gradually order them so they go out of stock one size after another, the dropdown would react accordingly and filter out those out-of-stock sizes. Still it does display out-of-stock sizes right after the new product is created via POST.
Am I right by choosing type_id=virtual to provide size options and quantities of physical products such as clothes?
Maybe there’s a way to debug this somehow.