From 8a0f0c69875073ca39069141718760232c48ad8d Mon Sep 17 00:00:00 2001 From: Josef Behr <mail@josef-behr.de> Date: Tue, 21 Feb 2017 17:23:16 +0100 Subject: [PATCH] Update Save.php If quantity is changed using mass action for attribute changes, but no stock item exists for the product, saving the newly created stockItem in StockItemRepository->save($stockItem) returns without saving the stockItem, since $stockItem->getProductId() is null, due to it being added to the array with key '0' (see line 165). To fix this, the array key has been changed to "product_id", such that StockItemRepository successfully creates the stockItem. Also, in my opinion, StockItemRepository->save() should not just return without notice, especially as it already encapsulates the functionality in a try/catch block. Throwing an exception would actually tell the user that something went wrong. --- .../Controller/Adminhtml/Product/Action/Attribute/Save.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php index e04d71b99cb9b..d8f4e204c1bb4 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php @@ -162,7 +162,7 @@ public function execute() $this->attributeHelper->getStoreWebsiteId($storeId) ); if (!$stockItemDo->getProductId()) { - $inventoryData[] = $productId; + $inventoryData['product_id'] = $productId; } $stockItemId = $stockItemDo->getId();