Magento SQL – Set Manage Stock 1 for All Simple Products

MySQLstock

I would like to update all my simple products in database by direct sql to set "manage stock" to 1 but don't know how to start.

Best Answer

Magento basically mapped products and its inventory to cataloginventory_stock_item .

As you want to update and then you need update the columns at manage_stock, `use_config_manage_stock,is_in_stock.

You can get simple product list from catalog_product_entity

SELECT entity_id FROM catalog_product_entity where type_id='simple'.

Now You can fill your requirement by

UPDATE cataloginventory_stock_item SET is_in_stock=1 , 
use_config_manage_stock =1,is_in_stock=1 where 
product_id in 
(SELECT entity_id FROM catalog_product_entity where type_id='simple')