cancel
Showing results for 
Search instead for 
Did you mean: 

Configurable product wrongly set as 'Out of Stock'

SOLVED

Configurable product wrongly set as 'Out of Stock'

Hello,

 

I use many configurable products.
There are 2 sources (other than default) and there is also other than default
All child products use the custom stock and sources (not the default one).

 

After reindexing all configurable products are set to Out of Stock.

When looking to table 'inventory_stock_2' in the database, there are many items where quantity>0 and is_salable=0. Well, all confugirable products.

 

If I update this in the database 

UPDATE inventory_stock_2 SET is_salable=1 WHERE quantity>0 and is_salable=0;

then all products are normally displayed in the store, but next reindexing change stock status back to Out of Stock. 
All child simple products have always correct stock status.

 

This problem occured only about 2 weeks ago, but I cannot say what preceded this issue.

I did some product updates via Magento Import and also I tested some product imports via REST API and unfortunatelly I was stupid enough to run at least some tests on production version, even if I have also test environment.

 

Later I notice not just this issue, but also 'Default stock' was added to all products. I have manually deleted the Default Stock from the products, but the problem with stock status still persists.

 

How can I fix this or check where the problem is?

(Magento 2.4.3-p1)

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Configurable product wrongly set as 'Out of Stock'

At the end I learnt that all configurable products where somehow set as Out Of Stock.

The only way how to mass change the status I found was following SQL query:

UPDATE cataloginventory_stock_item
INNER JOIN catalog_product_entity ON product_id=catalog_product_entity.entity_id
SET is_in_stock = 1
WHERE type_id="configurable";

View solution in original post

3 REPLIES 3

Re: Configurable product wrongly set as 'Out of Stock'

Hello @Peter_Karak,

Greetings to you!

If you ever find a Magento shopping cart is erroneously showing ‘in stock’ items as being ‘out of stock’ and you have ‘Manage Stock‘ set to ‘yes‘ under System > Configuration > Catalog > Inventory then you have probably hit a bug in Magento.

When you create configurable products in Magento, edit each of the simple products created from it:
  1. Ensure each simple product is set to ‘In Stock’ under the Inventory tab
  2. Ensure each simple product is assigned to a category
If your products are already created you will need all simple products created from the same parent configurable (base) product to check that each simple product (ie variation) is assigned a category and is not set to 'Out of Stock'.
 
If even one of them is set to ‘Out of Stock’ under Inventory > Stock Availability then the base (configurable) product will display the ‘Out of Stock’ message.
 
I hope this will help you to resolve your issue.
If not, feel free to contact us.
 
Solved? Click KUDOS and accept it as a solution.
Thank you!

Re: Configurable product wrongly set as 'Out of Stock'

At the end I learnt that all configurable products where somehow set as Out Of Stock.

The only way how to mass change the status I found was following SQL query:

UPDATE cataloginventory_stock_item
INNER JOIN catalog_product_entity ON product_id=catalog_product_entity.entity_id
SET is_in_stock = 1
WHERE type_id="configurable";

Re: Configurable product wrongly set as 'Out of Stock'

Thanks for your suggestion. Not sure it was my case. I learnt all my configurable products were for some strange reason set as Out Of Stock. Once I changed all of them to In Stock, everything works as expected. I managed to do it via SQL. otherwise it would not be possible due to large number of products