Closed
Description
Preconditions
- Clean install of Magento 2.1.0
- PHP 7
- MySQL 5.6
- Code works fine on 2.0.4
Steps to reproduce
- Create a product
- Load product
$product->load(1)
- Attempt to update product stock:
/**
* @var \Magento\Catalog\Model\Product
*/
$product->load(1);
/**
* @var \Magento\CatalogInventory\Api\StockRegistryInterface
*/
$productStockData = $this->stockRegistry->getStockItem($product->getId());
$productStockData->setData('is_in_stock', 1);
$productStockData->setData('qty', 5);
$productStockData->setData('manage_stock', 1);
$productStockData->save();
$product->save();
Expected result
- The product should update its stock data and set to manage stock as true.
Actual result
- The product does not change stock data and does not throw an exception or warning.
I'm able to set the products weight and other attributes just fine with similar code, but cannot change its stock data after the product has been created.