Skip to content

Commit 09cc1f6

Browse files
committed
ACP2E-1620: [QUANS] Scheduled import successfully runs despite errors in system.log file
- Fixed the CR comments.
1 parent 513119b commit 09cc1f6

File tree

2 files changed

+33
-25
lines changed

2 files changed

+33
-25
lines changed

app/code/Magento/ImportExport/Controller/Adminhtml/ImportResult.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingError;
1212
use Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregatorInterface;
1313
use Magento\ImportExport\Model\History as ModelHistory;
14+
use Magento\Framework\Escaper;
1415
use Magento\Framework\App\ObjectManager;
1516
use Magento\ImportExport\Model\Import\RenderErrorMessages;
1617
use Magento\ImportExport\Model\Report\ReportProcessorInterface;
@@ -42,6 +43,11 @@ abstract class ImportResult extends Import
4243
*/
4344
protected Report $reportHelper;
4445

46+
/**
47+
* @var Escaper|null
48+
*/
49+
protected $escaper;
50+
4551
/**
4652
* @var RenderErrorMessages
4753
*/
@@ -52,19 +58,23 @@ abstract class ImportResult extends Import
5258
* @param ReportProcessorInterface $reportProcessor
5359
* @param ModelHistory $historyModel
5460
* @param Report $reportHelper
61+
* @param Escaper|null $escaper
5562
* @param RenderErrorMessages|null $renderErrorMessages
5663
*/
5764
public function __construct(
5865
Context $context,
5966
ReportProcessorInterface $reportProcessor,
6067
ModelHistory $historyModel,
6168
Report $reportHelper,
69+
Escaper $escaper = null,
6270
?RenderErrorMessages $renderErrorMessages = null
6371
) {
6472
parent::__construct($context);
6573
$this->reportProcessor = $reportProcessor;
6674
$this->historyModel = $historyModel;
6775
$this->reportHelper = $reportHelper;
76+
$this->escaper = $escaper
77+
?? ObjectManager::getInstance()->get(Escaper::class);
6878
$this->renderErrorMessages = $renderErrorMessages ??
6979
ObjectManager::getInstance()->get(RenderErrorMessages::class);
7080
}

app/code/Magento/ImportExport/Model/Import/RenderErrorMessages.php

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -75,37 +75,35 @@ public function __construct(
7575
* Add Error Messages for Import
7676
*
7777
* @param ProcessingErrorAggregatorInterface $errorAggregator
78-
* @return string|void
78+
* @return string
7979
*/
8080
public function renderMessages(
8181
ProcessingErrorAggregatorInterface $errorAggregator
82-
) {
83-
if ($errorAggregator->getErrorsCount()) {
84-
$message = '';
85-
$counter = 0;
86-
$escapedMessages = [];
87-
foreach ($this->getErrorMessages($errorAggregator) as $error) {
88-
$escapedMessages[] = (++$counter) . '. ' . $this->escaper->escapeHtml($error);
89-
if ($counter >= ImportResult::LIMIT_ERRORS_MESSAGE) {
90-
break;
91-
}
82+
): string {
83+
$message = '';
84+
$counter = 0;
85+
$escapedMessages = [];
86+
foreach ($this->getErrorMessages($errorAggregator) as $error) {
87+
$escapedMessages[] = (++$counter) . '. ' . $this->escaper->escapeHtml($error);
88+
if ($counter >= ImportResult::LIMIT_ERRORS_MESSAGE) {
89+
break;
9290
}
93-
if ($errorAggregator->hasFatalExceptions()) {
94-
foreach ($this->getSystemExceptions($errorAggregator) as $error) {
95-
$escapedMessages[] = $this->escaper->escapeHtml($error->getErrorMessage())
96-
. ' <a href="#" onclick="$(this).next().show();$(this).hide();return false;">'
97-
. __('Show more') . '</a><div style="display:none;">' . __('Additional data') . ': '
98-
. $this->escaper->escapeHtml($error->getErrorDescription()) . '</div>';
99-
}
91+
}
92+
if ($errorAggregator->hasFatalExceptions()) {
93+
foreach ($this->getSystemExceptions($errorAggregator) as $error) {
94+
$escapedMessages[] = $this->escaper->escapeHtml($error->getErrorMessage())
95+
. ' <a href="#" onclick="$(this).next().show();$(this).hide();return false;">'
96+
. __('Show more') . '</a><div style="display:none;">' . __('Additional data') . ': '
97+
. $this->escaper->escapeHtml($error->getErrorDescription()) . '</div>';
10098
}
101-
$message .= implode('<br>', $escapedMessages);
102-
return '<strong>' . __('Following Error(s) has been occurred during importing process:') . '</strong><br>'
103-
. '<div class="import-error-wrapper">' . __('Only the first 100 errors are shown. ')
104-
. '<a href="'
105-
. $this->createDownloadUrlImportHistoryFile($this->createErrorReport($errorAggregator))
106-
. '">' . __('Download full report') . '</a><br>'
107-
. '<div class="import-error-list">' . $message . '</div></div>';
10899
}
100+
$message .= implode('<br>', $escapedMessages);
101+
return '<strong>' . __('Following Error(s) has been occurred during importing process:') . '</strong><br>'
102+
. '<div class="import-error-wrapper">' . __('Only the first 100 errors are shown. ')
103+
. '<a href="'
104+
. $this->createDownloadUrlImportHistoryFile($this->createErrorReport($errorAggregator))
105+
. '">' . __('Download full report') . '</a><br>'
106+
. '<div class="import-error-list">' . $message . '</div></div>';
109107
}
110108

111109
/**

0 commit comments

Comments
 (0)