questions

0 Answers

Set manage_stock status to 1 programmatically with php

Asked by: Prashant Sharma 2832 views Questions

I’m importing products from CSV file. Everything else is going fine but when i try to save item’s stock info(‘is_in_stock’, ‘manage_stock’, ‘qty’ etc.), it does’nt get saved into database. I’m using following code:

        $stockData = $product->getStockItem();
        $stockData['is_in_stock'] = ’1′;
        $stockData['manage_stock'] = ’1′;
        $stockData['use_config_manage_stock'] = ’1′;
        $stockData['qty'] = ’25′;
        $product->setStockItem($stockData);
        $product->save();

Answer Question