0

I am updating is_in_stock field in cataloginventory_stock_item as follows:

UPDATE cataloginventory_stock_item ci SET ci.is_in_stock = CASE WHEN ci.qty = 0 THEN 0 WHEN ci.qty > 0 THEN 1 END WHERE product_id in (1968,1969);

I then Reindex All & Flush Cache: Changes have been applied to cataloginventory_stock_item & cataloginventory_stock_status But Products are still showing Out of Stock on website

Note: If I go to Magento Dashboard -> Catalog -> Products and mark the product Out of Stock and then back to In Stock it works. (But I don't want to do this for 2,000 products)

Any ideas? Thanks in Advance!

2
  • which magento version are you using?
    – Diana
    Commented Mar 8, 2021 at 16:36
  • Magento version 2.3
    – Skater
    Commented Mar 8, 2021 at 16:40

2 Answers 2

1

I resolved this myself:

status field in table: cataloginventory_stock_item needed to be updated to 1

FYI found the tables that were being updated by using:

select table_schema as database_name, table_name, update_time from information_schema.tables tab where update_time > (current_timestamp() - interval 30 day) and table_type = 'BASE TABLE' and table_schema not in ('information_schema', 'sys', 'performance_schema','mysql') -- and table_schema = 'your database name' order by update_time desc;

0

Anyone looking for a fix.

vendor/magento/module-inventory-catalog/Model/ResourceModel/StockStatusExpressionForDefaultStock.php

Line 49,

$connection->getCheckSql('css.stock_status IS NOT NULL', 'css.stock_status', $stockItemInStockField) 
Change to:
$connection->getCheckSql('css.stock_status IS NOT NULL', 'cisi.is_in_stock', $stockItemInStockField)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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