Skip to content

Commit 8dd0ed6

Browse files
author
Kristian Charbonneau
committed
Update stock status on CSV Product import according to quantity
If the is_in_stock field is not present in a particular row in the CSV file and the qty field is set to 0, the default is_in_stock value is overriden from 1 to 0.
1 parent cc23756 commit 8dd0ed6

File tree

1 file changed

+4
-0
lines changed
  • app/code/Magento/CatalogImportExport/Model/Import

1 file changed

+4
-0
lines changed

app/code/Magento/CatalogImportExport/Model/Import/Product.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2972,6 +2972,10 @@ private function formatStockDataForRow(array $rowData): array
29722972
$stockItemDo = $this->stockRegistry->getStockItem($row['product_id'], $row['website_id']);
29732973
$existStockData = $stockItemDo->getData();
29742974

2975+
if (isset($rowData['qty']) && $rowData['qty'] == 0 && !isset($rowData['is_in_stock'])) {
2976+
$rowData['is_in_stock'] = 0;
2977+
}
2978+
29752979
$row = array_merge(
29762980
$this->defaultStockData,
29772981
array_intersect_key($existStockData, $this->defaultStockData),

0 commit comments

Comments
 (0)