We have gotten an API from our manufacturer, now we want to enable stock in these products and give them the right quantity...
We use this code:
$_product->setData('use_config_manage_stock', 0);
$_product->setData('manage_stock', 1); // should be 1 to make something out of stock
$_product->setData('is_in_stock', 1); // is 0 or 1
$_product->setData('qty', 1234);
try {
$_product->save();
echo "done." . PHP_EOL;
} catch (Exception $e) {
echo "{$e}";
}
But for some reason, stock wont be enabled on these products and the quantity is also not applied... Whats wrong with this code?!
this is how the products are normal and even after the script it stays like that http://puu.sh/di3RT/f9ecfc32ce.png
Thanks in Advance,