Skip to content

Commit 2731834

Browse files
MacMac
authored andcommitted
Merge remote-tracking branch 'remotes/github/MAGETWO-91640' into EPAM-PR-28
2 parents b8e3a0b + ef2dccf commit 2731834

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
namespace Magento\ImportExport\Model;
88

99
use Magento\Framework\App\Filesystem\DirectoryList;
10+
use Magento\Framework\App\ObjectManager;
1011
use Magento\Framework\HTTP\Adapter\FileTransferFactory;
1112
use Magento\Framework\Stdlib\DateTime\DateTime;
1213
use Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingError;
1314
use Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregatorInterface;
15+
use Magento\Framework\Message\ManagerInterface;
1416

1517
/**
1618
* Import model
@@ -179,6 +181,11 @@ class Import extends \Magento\ImportExport\Model\AbstractModel
179181
*/
180182
private $localeDate;
181183

184+
/**
185+
* @var ManagerInterface
186+
*/
187+
private $messageManager;
188+
182189
/**
183190
* @param \Psr\Log\LoggerInterface $logger
184191
* @param \Magento\Framework\Filesystem $filesystem
@@ -195,6 +202,7 @@ class Import extends \Magento\ImportExport\Model\AbstractModel
195202
* @param History $importHistoryModel
196203
* @param DateTime $localeDate
197204
* @param array $data
205+
* @param ManagerInterface|null $messageManager
198206
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
199207
*/
200208
public function __construct(
@@ -212,7 +220,8 @@ public function __construct(
212220
\Magento\Framework\Indexer\IndexerRegistry $indexerRegistry,
213221
\Magento\ImportExport\Model\History $importHistoryModel,
214222
DateTime $localeDate,
215-
array $data = []
223+
array $data = [],
224+
ManagerInterface $messageManager = null
216225
) {
217226
$this->_importExportData = $importExportData;
218227
$this->_coreConfig = $coreConfig;
@@ -227,6 +236,7 @@ public function __construct(
227236
$this->_filesystem = $filesystem;
228237
$this->importHistoryModel = $importHistoryModel;
229238
$this->localeDate = $localeDate;
239+
$this->messageManager = $messageManager ?: ObjectManager::getInstance()->get(ManagerInterface::class);
230240
parent::__construct($logger, $filesystem, $data);
231241
}
232242

@@ -620,9 +630,13 @@ public function validateSource(\Magento\ImportExport\Model\Import\AbstractSource
620630
$messages = $this->getOperationResultMessages($errorAggregator);
621631
$this->addLogComment($messages);
622632

623-
$result = !$errorAggregator->getErrorsCount();
633+
$errorsCount = $errorAggregator->getErrorsCount();
634+
$result = !$errorsCount;
624635
$validationStrategy = $this->getData(self::FIELD_NAME_VALIDATION_STRATEGY);
625-
if ($validationStrategy === ProcessingErrorAggregatorInterface::VALIDATION_STRATEGY_SKIP_ERRORS) {
636+
if ($errorsCount
637+
&& $validationStrategy === ProcessingErrorAggregatorInterface::VALIDATION_STRATEGY_SKIP_ERRORS
638+
) {
639+
$this->messageManager->addWarningMessage(__('Skipped errors: %1', $errorsCount));
626640
$result = true;
627641
}
628642

0 commit comments

Comments
 (0)