Пример #1
0
 /**
  * @param int $rowNumber
  * @param ProcessingErrorAggregatorInterface $errorAggregator
  * @return string
  */
 public function retrieveErrorMessagesByRowNumber($rowNumber, ProcessingErrorAggregatorInterface $errorAggregator)
 {
     $messages = '';
     foreach ($errorAggregator->getErrorByRowNumber((int) $rowNumber) as $error) {
         $messages .= $error->getErrorMessage() . ',';
     }
     $messages = rtrim($messages, ',');
     if ($messages) {
         $messages = str_pad($messages, 1, '"', STR_PAD_BOTH);
     }
     return $messages;
 }
Пример #2
0
 /**
  * Return operation result messages
  *
  * @param ProcessingErrorAggregatorInterface $validationResult
  * @return string[]
  */
 public function getOperationResultMessages(ProcessingErrorAggregatorInterface $validationResult)
 {
     $messages = [];
     if ($this->getProcessedRowsCount()) {
         if ($validationResult->getErrorsCount()) {
             $messages[] = __('Data validation is failed. Please fix errors and re-upload the file.');
             // errors info
             foreach ($validationResult->getRowsGroupedByErrorCode() as $errorMessage => $rows) {
                 $error = $errorMessage . ' ' . __('in rows') . ': ' . implode(', ', $rows);
                 $messages[] = $error;
             }
         } else {
             if ($this->isImportAllowed()) {
                 $messages[] = __('The validation is complete.');
             } else {
                 $messages[] = __('The file is valid, but we can\'t import it for some reason.');
             }
         }
         $messages[] = __('Checked rows: %1, checked entities: %2, invalid rows: %3, total errors: %4', $this->getProcessedRowsCount(), $this->getProcessedEntitiesCount(), $validationResult->getInvalidRowsCount(), $validationResult->getErrorsCount([ProcessingError::ERROR_LEVEL_CRITICAL, ProcessingError::ERROR_LEVEL_NOT_CRITICAL]));
     } else {
         $messages[] = __('This file does not contain any data.');
     }
     return $messages;
 }
Пример #3
0
 /**
  * @param ProcessingErrorAggregatorInterface $errorAggregator
  * @return \Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingError[]
  */
 protected function getSystemExceptions(ProcessingErrorAggregatorInterface $errorAggregator)
 {
     return $errorAggregator->getErrorsByCode([AbstractEntity::ERROR_CODE_SYSTEM_EXCEPTION]);
 }