7
7
namespace Magento \ImportExport \Model ;
8
8
9
9
use Magento \Framework \App \Filesystem \DirectoryList ;
10
+ use Magento \Framework \App \ObjectManager ;
10
11
use Magento \Framework \HTTP \Adapter \FileTransferFactory ;
11
12
use Magento \ImportExport \Model \Import \ErrorProcessing \ProcessingError ;
12
13
use Magento \ImportExport \Model \Import \ErrorProcessing \ProcessingErrorAggregatorInterface ;
14
+ use Magento \Framework \Message \ManagerInterface ;
13
15
14
16
/**
15
17
* Import model
@@ -167,6 +169,11 @@ class Import extends \Magento\ImportExport\Model\AbstractModel
167
169
*/
168
170
protected $ _filesystem ;
169
171
172
+ /**
173
+ * @var ManagerInterface
174
+ */
175
+ private $ messageManager ;
176
+
170
177
/**
171
178
* @param \Psr\Log\LoggerInterface $logger
172
179
* @param \Magento\Framework\Filesystem $filesystem
@@ -183,6 +190,7 @@ class Import extends \Magento\ImportExport\Model\AbstractModel
183
190
* @param History $importHistoryModel
184
191
* @param \Magento\Framework\Stdlib\DateTime\DateTime $localeDate
185
192
* @param array $data
193
+ * @param ManagerInterface|null $messageManager
186
194
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
187
195
*/
188
196
public function __construct (
@@ -200,7 +208,8 @@ public function __construct(
200
208
\Magento \Framework \Indexer \IndexerRegistry $ indexerRegistry ,
201
209
\Magento \ImportExport \Model \History $ importHistoryModel ,
202
210
\Magento \Framework \Stdlib \DateTime \DateTime $ localeDate ,
203
- array $ data = []
211
+ array $ data = [],
212
+ ManagerInterface $ messageManager = null
204
213
) {
205
214
$ this ->_importExportData = $ importExportData ;
206
215
$ this ->_coreConfig = $ coreConfig ;
@@ -215,6 +224,7 @@ public function __construct(
215
224
$ this ->_filesystem = $ filesystem ;
216
225
$ this ->importHistoryModel = $ importHistoryModel ;
217
226
$ this ->localeDate = $ localeDate ;
227
+ $ this ->messageManager = $ messageManager ?: ObjectManager::getInstance ()->get (ManagerInterface::class);
218
228
parent ::__construct ($ logger , $ filesystem , $ data );
219
229
}
220
230
@@ -588,9 +598,13 @@ public function validateSource(\Magento\ImportExport\Model\Import\AbstractSource
588
598
$ messages = $ this ->getOperationResultMessages ($ errorAggregator );
589
599
$ this ->addLogComment ($ messages );
590
600
591
- $ result = !$ errorAggregator ->getErrorsCount ();
601
+ $ errorsCount = $ errorAggregator ->getErrorsCount ();
602
+ $ result = !$ errorsCount ;
592
603
$ validationStrategy = $ this ->getData (self ::FIELD_NAME_VALIDATION_STRATEGY );
593
- if ($ validationStrategy === ProcessingErrorAggregatorInterface::VALIDATION_STRATEGY_SKIP_ERRORS ) {
604
+ if ($ errorsCount
605
+ && $ validationStrategy === ProcessingErrorAggregatorInterface::VALIDATION_STRATEGY_SKIP_ERRORS
606
+ ) {
607
+ $ this ->messageManager ->addWarningMessage (sprintf (__ ('Skipped errors: %d ' ), $ errorsCount ));
594
608
$ result = true ;
595
609
}
596
610
0 commit comments