In the following code, I am able to store all the information with the exclusion of the stock data. Has something changed in Magento 2?
public function __construct(
ScopeConfigInterface $scopeConfig, CollectionFactory $product,
Magento\Catalog\Api\ProductRepositoryInterface $productRepository
) {
$this->scopeConfig = $scopeConfig;
$this->product = $product;
$this->productRepository = $productRepository;
}
public function update(\XXXXXX\XXXXXX\Api\Data\InventoryCollectionInterface $data) {
foreach ($data['list'] as $d) {
$product = $this->productRepository->getById($d['entity_id']);
$product->setStatus(($d['quantity'] > 0 ? 1 : 0));
$product->setUpc($d['upc']);
$product->setStockData(array(
'qty' => $d['quantity'],
'is_in_stock' => ($d['quantity'] > 0 ? 1 : 0)
));
$this->productRepository->save($product);
}
return "Done";
}