From ea20de5ab32b1c70ac23c6e01917430b74592f0e Mon Sep 17 00:00:00 2001 From: David Stone Date: Thu, 2 Aug 2018 10:09:17 -0600 Subject: [PATCH] Allow import to skip errors buy making them non-critical --- .../ImportExport/Controller/Adminhtml/Import/Validate.php | 2 +- app/code/Magento/ImportExport/Model/Import.php | 5 +++++ .../Magento/ImportExport/Model/Import/AbstractEntity.php | 2 +- .../ImportExport/Model/Import/Entity/AbstractEntity.php | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/ImportExport/Controller/Adminhtml/Import/Validate.php b/app/code/Magento/ImportExport/Controller/Adminhtml/Import/Validate.php index df9f63e79b75e..d840e0b759118 100644 --- a/app/code/Magento/ImportExport/Controller/Adminhtml/Import/Validate.php +++ b/app/code/Magento/ImportExport/Controller/Adminhtml/Import/Validate.php @@ -132,7 +132,7 @@ private function getImport() private function addMessageToSkipErrors(Result $resultBlock) { $import = $this->getImport(); - if (!$import->getErrorAggregator()->hasFatalExceptions()) { + if (!$import->getErrorAggregator()->hasToBeTerminated()) { $resultBlock->addSuccess( __('Please fix errors and re-upload file or simply press "Import" button to skip rows with errors'), true diff --git a/app/code/Magento/ImportExport/Model/Import.php b/app/code/Magento/ImportExport/Model/Import.php index 092b721b82435..ddd01eca2c3bc 100644 --- a/app/code/Magento/ImportExport/Model/Import.php +++ b/app/code/Magento/ImportExport/Model/Import.php @@ -409,6 +409,11 @@ public function importSource() $this->addLogComment(__('Begin import of "%1" with "%2" behavior', $this->getEntity(), $this->getBehavior())); + $this->getErrorAggregator()->initValidationStrategy( + $this->getData(self::FIELD_NAME_VALIDATION_STRATEGY), + $this->getData(self::FIELD_NAME_ALLOWED_ERROR_COUNT) + ); + $result = $this->processImport(); if ($result) { diff --git a/app/code/Magento/ImportExport/Model/Import/AbstractEntity.php b/app/code/Magento/ImportExport/Model/Import/AbstractEntity.php index 979ac97928254..45a0d57df9717 100644 --- a/app/code/Magento/ImportExport/Model/Import/AbstractEntity.php +++ b/app/code/Magento/ImportExport/Model/Import/AbstractEntity.php @@ -517,7 +517,7 @@ public function addRowError( $errorRowNum, $colName = null, $errorMessage = null, - $errorLevel = ProcessingError::ERROR_LEVEL_CRITICAL, + $errorLevel = ProcessingError::ERROR_LEVEL_NOT_CRITICAL, $errorDescription = null ) { $errorCode = (string)$errorCode; diff --git a/app/code/Magento/ImportExport/Model/Import/Entity/AbstractEntity.php b/app/code/Magento/ImportExport/Model/Import/Entity/AbstractEntity.php index f5dca6a19651d..c683c22b61b1e 100644 --- a/app/code/Magento/ImportExport/Model/Import/Entity/AbstractEntity.php +++ b/app/code/Magento/ImportExport/Model/Import/Entity/AbstractEntity.php @@ -469,7 +469,7 @@ public function addRowError( $errorRowNum, $colName = null, $errorMessage = null, - $errorLevel = ProcessingError::ERROR_LEVEL_CRITICAL, + $errorLevel = ProcessingError::ERROR_LEVEL_NOT_CRITICAL, $errorDescription = null ) { $errorCode = (string)$errorCode;