@@ -193,6 +193,11 @@ class Import extends AbstractModel
193
193
*/
194
194
private $ messageManager ;
195
195
196
+ /**
197
+ * @var SourceFactory
198
+ */
199
+ private $ sourceFactory ;
200
+
196
201
/**
197
202
* @var Upload
198
203
*/
@@ -215,6 +220,7 @@ class Import extends AbstractModel
215
220
* @param DateTime $localeDate
216
221
* @param array $data
217
222
* @param ManagerInterface|null $messageManager
223
+ * @param SourceFactory|null $sourceFactory
218
224
* @param Upload|null $upload
219
225
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
220
226
*/
@@ -235,6 +241,7 @@ public function __construct(
235
241
DateTime $ localeDate ,
236
242
array $ data = [],
237
243
ManagerInterface $ messageManager = null ,
244
+ SourceFactory $ sourceFactory = null ,
238
245
Upload $ upload = null
239
246
) {
240
247
$ this ->_importExportData = $ importExportData ;
@@ -252,6 +259,8 @@ public function __construct(
252
259
$ this ->localeDate = $ localeDate ;
253
260
$ this ->messageManager = $ messageManager ?: ObjectManager::getInstance ()
254
261
->get (ManagerInterface::class);
262
+ $ this ->sourceFactory = $ sourceFactory ?? ObjectManager::getInstance ()
263
+ ->get (SourceFactory::class);
255
264
$ this ->upload = $ upload ?: ObjectManager::getInstance ()
256
265
->get (Upload::class);
257
266
parent ::__construct ($ logger , $ filesystem , $ data );
@@ -304,7 +313,6 @@ protected function _getEntityAdapter()
304
313
305
314
/**
306
315
* Returns source adapter object.
307
- *
308
316
* @Deprecated
309
317
* @see \Magento\ImportExport\Model\Import\Source\Factory::create()
310
318
* @param string $sourceFile Full path to source file
@@ -576,7 +584,11 @@ public function uploadFileAndGetSource()
576
584
{
577
585
$ sourceFile = $ this ->uploadSource ();
578
586
try {
579
- $ source = $ this ->_getSourceAdapter ($ sourceFile );
587
+ $ source = $ this ->sourceFactory ->create (
588
+ $ sourceFile ,
589
+ $ this ->_filesystem ->getDirectoryWrite (DirectoryList::ROOT ),
590
+ $ this ->getData (self ::FIELD_FIELD_SEPARATOR )
591
+ );
580
592
} catch (\Exception $ e ) {
581
593
$ this ->_varDirectory ->delete ($ this ->_varDirectory ->getRelativePath ($ sourceFile ));
582
594
throw new LocalizedException (__ ($ e ->getMessage ()));
0 commit comments