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 \Framework \Stdlib \DateTime \DateTime ;
12
13
use Magento \ImportExport \Model \Import \ErrorProcessing \ProcessingError ;
13
14
use Magento \ImportExport \Model \Import \ErrorProcessing \ProcessingErrorAggregatorInterface ;
15
+ use Magento \Framework \Message \ManagerInterface ;
14
16
15
17
/**
16
18
* Import model
@@ -179,6 +181,11 @@ class Import extends \Magento\ImportExport\Model\AbstractModel
179
181
*/
180
182
private $ localeDate ;
181
183
184
+ /**
185
+ * @var ManagerInterface
186
+ */
187
+ private $ messageManager ;
188
+
182
189
/**
183
190
* @param \Psr\Log\LoggerInterface $logger
184
191
* @param \Magento\Framework\Filesystem $filesystem
@@ -195,6 +202,7 @@ class Import extends \Magento\ImportExport\Model\AbstractModel
195
202
* @param History $importHistoryModel
196
203
* @param DateTime $localeDate
197
204
* @param array $data
205
+ * @param ManagerInterface|null $messageManager
198
206
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
199
207
*/
200
208
public function __construct (
@@ -212,7 +220,8 @@ public function __construct(
212
220
\Magento \Framework \Indexer \IndexerRegistry $ indexerRegistry ,
213
221
\Magento \ImportExport \Model \History $ importHistoryModel ,
214
222
DateTime $ localeDate ,
215
- array $ data = []
223
+ array $ data = [],
224
+ ManagerInterface $ messageManager = null
216
225
) {
217
226
$ this ->_importExportData = $ importExportData ;
218
227
$ this ->_coreConfig = $ coreConfig ;
@@ -227,6 +236,7 @@ public function __construct(
227
236
$ this ->_filesystem = $ filesystem ;
228
237
$ this ->importHistoryModel = $ importHistoryModel ;
229
238
$ this ->localeDate = $ localeDate ;
239
+ $ this ->messageManager = $ messageManager ?: ObjectManager::getInstance ()->get (ManagerInterface::class);
230
240
parent ::__construct ($ logger , $ filesystem , $ data );
231
241
}
232
242
@@ -620,9 +630,13 @@ public function validateSource(\Magento\ImportExport\Model\Import\AbstractSource
620
630
$ messages = $ this ->getOperationResultMessages ($ errorAggregator );
621
631
$ this ->addLogComment ($ messages );
622
632
623
- $ result = !$ errorAggregator ->getErrorsCount ();
633
+ $ errorsCount = $ errorAggregator ->getErrorsCount ();
634
+ $ result = !$ errorsCount ;
624
635
$ 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 ));
626
640
$ result = true ;
627
641
}
628
642
0 commit comments