Last active
February 5, 2021 08:27
-
-
Save tangar76/991b4423cd9baaac79381422581951c0 to your computer and use it in GitHub Desktop.
Fixed stock status to "Out of Stock" after product import even product allowed backorders. .../module-catalog-import-export/Model/Import/Product.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- /vendor/magento/module-catalog-import-export/Model/Import/Product.php | |
+++ /vendor/magento/module-catalog-import-export/Model/Import/Product.php (Unsaved) | |
@@ -3062,7 +3062,9 @@ | |
$stockItemDo = $this->stockRegistry->getStockItem($row['product_id'], $row['website_id']); | |
$existStockData = $stockItemDo->getData(); | |
- if (isset($rowData['qty']) && $rowData['qty'] == 0 && !isset($rowData['is_in_stock'])) { | |
+ if (isset($rowData['qty']) && $rowData['qty'] == 0 && !isset($rowData['is_in_stock']) | |
+ && empty($existStockData['backorders']) // backorders not set or set to 0 | |
+ ) { | |
$rowData['is_in_stock'] = 0; | |
} | |
@@ -3074,7 +3076,9 @@ | |
); | |
if ($this->stockConfiguration->isQty($this->skuProcessor->getNewSku($sku)['type_id'])) { | |
- if (isset($rowData['qty']) && $rowData['qty'] == 0) { | |
+ if (isset($rowData['qty']) && $rowData['qty'] == 0 | |
+ && empty($existStockData['backorders']) // backorders not set or set to 0 | |
+ ) { | |
$row['is_in_stock'] = 0; | |
} | |
$stockItemDo->setData($row); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment