Exemple #1
0
 /**
  * @param bool $validationResult
  * @param ImportResultBlock $resultBlock
  * @return void
  */
 private function processValidationResult($validationResult, $resultBlock)
 {
     $import = $this->getImport();
     if (!$import->getProcessedRowsCount()) {
         if (!$import->getErrorAggregator()->getErrorsCount()) {
             $resultBlock->addError(__('This file is empty. Please try another one.'));
         } else {
             foreach ($import->getErrorAggregator()->getAllErrors() as $error) {
                 $resultBlock->addError($error->getErrorMessage());
             }
         }
     } else {
         $errorAggregator = $import->getErrorAggregator();
         if (!$validationResult) {
             $resultBlock->addError(__('Data validation failed. Please fix the following errors and upload the file again.'));
             $this->addErrorMessages($resultBlock, $errorAggregator);
         } else {
             if ($import->isImportAllowed()) {
                 $resultBlock->addSuccess(__('File is valid! To start import process press "Import" button'), true);
             } else {
                 $resultBlock->addError(__('The file is valid, but we can\'t import it for some reason.'));
             }
         }
         $resultBlock->addNotice(__('Checked rows: %1, checked entities: %2, invalid rows: %3, total errors: %4', $import->getProcessedRowsCount(), $import->getProcessedEntitiesCount(), $errorAggregator->getInvalidRowsCount(), $errorAggregator->getErrorsCount()));
     }
 }
Exemple #2
0
 /**
  * Process validation results
  *
  * @param \Magento\ImportExport\Model\Import $import
  * @param \Magento\ImportExport\Block\Adminhtml\Import\Frame\Result $resultBlock
  * @return void
  */
 protected function processValidationError(Import $import, ImportResultBlock $resultBlock)
 {
     if ($import->getProcessedRowsCount() == $import->getInvalidRowsCount()) {
         $resultBlock->addNotice(__('File is totally invalid. Please fix errors and re-upload file.'));
     } elseif ($import->getErrorsCount() >= $import->getErrorsLimit()) {
         $resultBlock->addNotice(__('Errors limit (%1) reached. Please fix errors and re-upload file.', $import->getErrorsLimit()));
     } else {
         if ($import->isImportAllowed()) {
             $resultBlock->addNotice(__('Please fix errors and re-upload file or simply press "Import" button to skip rows with errors'), true);
         } else {
             $resultBlock->addNotice(__('File is partially valid, but import is not possible'), false);
         }
     }
     // errors info
     foreach ($import->getErrors() as $errorCode => $rows) {
         $error = $errorCode . ' ' . __('in rows:') . ' ' . implode(', ', $rows);
         $resultBlock->addError($error);
     }
 }
Exemple #3
0
 /**
  * Process validation results
  *
  * @param \Magento\ImportExport\Model\Import $import
  * @param \Magento\ImportExport\Block\Adminhtml\Import\Frame\Result $resultBlock
  * @return void
  */
 protected function processValidationError(Import $import, ImportResultBlock $resultBlock)
 {
     if ($import->getProcessedRowsCount() == $import->getInvalidRowsCount()) {
         $resultBlock->addNotice(__('This file is invalid. Please fix errors and re-upload the file.'));
     } elseif ($import->getErrorsCount() >= $import->getErrorsLimit()) {
         $resultBlock->addNotice(__('You\'ve reached an error limit (%1). Please fix errors and re-upload the file.', $import->getErrorsLimit()));
     } else {
         if ($import->isImportAllowed()) {
             $resultBlock->addNotice(__('Please fix errors and re-upload the file. Or press "Import" to skip rows with errors.'), true);
         } else {
             $resultBlock->addNotice(__('The file is partially valid, but we can\'t import it for some reason.'), false);
         }
     }
     // errors info
     foreach ($import->getErrors() as $errorCode => $rows) {
         $error = $errorCode . ' ' . __('in rows:') . ' ' . implode(', ', $rows);
         $resultBlock->addError($error);
     }
 }