Skip to content

Commit 1dd4b36

Browse files
author
Vadim Zubovich
committed
MAGNIMEX-392: Stabilize PR 1
Adding the same error twice fixed
1 parent 5c80068 commit 1dd4b36

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

app/code/Magento/ImportExport/Model/Import/ErrorProcessing/ProcessingErrorAggregator.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ public function addError(
7777
$errorMessage = null,
7878
$errorDescription = null
7979
) {
80+
if ($this->isErrorAlreadyAdded($rowNumber, $errorCode)) {
81+
return $this;
82+
}
8083
$this->processErrorStatistics($errorLevel);
8184
$this->processInvalidRow($rowNumber);
8285
$errorMessage = $this->getErrorMessage($errorCode, $errorMessage, $columnName);
@@ -227,6 +230,22 @@ public function getErrorsByCode(array $codes)
227230
return $result;
228231
}
229232

233+
/**
234+
* @param int $rowNumber
235+
* @return ProcessingError[]
236+
*/
237+
public function getErrorByRowNumber($rowNumber)
238+
{
239+
$result = [];
240+
foreach ($this->items as $error) {
241+
if ($error->getRowNumber() == (int)$rowNumber) {
242+
$result[] = $error;
243+
}
244+
}
245+
246+
return $result;
247+
}
248+
230249
/**
231250
* @param array $errorCode
232251
* @param array $excludedCodes
@@ -289,6 +308,22 @@ public function clear()
289308
return $this;
290309
}
291310

311+
/**
312+
* @param int $rowNum
313+
* @param string $errorCode
314+
* @return bool
315+
*/
316+
protected function isErrorAlreadyAdded($rowNum, $errorCode)
317+
{
318+
$errors = $this->getErrorsByCode([$errorCode]);
319+
foreach ($errors as $error) {
320+
if ($rowNum == $error->getRowNumber()) {
321+
return true;
322+
}
323+
}
324+
return false;
325+
}
326+
292327
/**
293328
* @param string $errorCode
294329
* @param string $errorMessage

app/code/Magento/ImportExport/Model/Import/ErrorProcessing/ProcessingErrorAggregatorInterface.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ public function getAllErrors();
9090
*/
9191
public function getErrorsByCode(array $codes);
9292

93+
/**
94+
* @param int $rowNumber
95+
* @return ProcessingError[]
96+
*/
97+
public function getErrorByRowNumber($rowNumber);
98+
9399
/**
94100
* @param array $errorCode
95101
* @param array $excludedCodes

0 commit comments

Comments
 (0)