Skip to content

Commit 4e6cc2d

Browse files
committed
ACPT-493: Upload csv with request parameter
1 parent 3a9f050 commit 4e6cc2d

File tree

2 files changed

+7
-23
lines changed

2 files changed

+7
-23
lines changed

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

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,6 @@ class Import extends AbstractModel
193193
*/
194194
private $messageManager;
195195

196-
/**
197-
* @var SourceFactory
198-
*/
199-
private $sourceFactory;
200-
201196
/**
202197
* @var Upload
203198
*/
@@ -220,7 +215,6 @@ class Import extends AbstractModel
220215
* @param DateTime $localeDate
221216
* @param array $data
222217
* @param ManagerInterface|null $messageManager
223-
* @param SourceFactory|null $sourceFactory
224218
* @param Upload|null $upload
225219
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
226220
*/
@@ -241,7 +235,6 @@ public function __construct(
241235
DateTime $localeDate,
242236
array $data = [],
243237
ManagerInterface $messageManager = null,
244-
SourceFactory $sourceFactory = null,
245238
Upload $upload = null
246239
) {
247240
$this->_importExportData = $importExportData;
@@ -259,8 +252,6 @@ public function __construct(
259252
$this->localeDate = $localeDate;
260253
$this->messageManager = $messageManager ?: ObjectManager::getInstance()
261254
->get(ManagerInterface::class);
262-
$this->sourceFactory = $sourceFactory?? ObjectManager::getInstance()
263-
->get(SourceFactory::class);
264255
$this->upload = $upload ?: ObjectManager::getInstance()
265256
->get(Upload::class);
266257
parent::__construct($logger, $filesystem, $data);
@@ -313,6 +304,7 @@ protected function _getEntityAdapter()
313304

314305
/**
315306
* Returns source adapter object.
307+
*
316308
* @Deprecated
317309
* @see \Magento\ImportExport\Model\Import\Source\Factory::create()
318310
* @param string $sourceFile Full path to source file
@@ -584,11 +576,7 @@ public function uploadFileAndGetSource()
584576
{
585577
$sourceFile = $this->uploadSource();
586578
try {
587-
$source = $this->sourceFactory->create(
588-
$sourceFile,
589-
$this->_filesystem->getDirectoryWrite(DirectoryList::ROOT),
590-
$this->getData(self::FIELD_FIELD_SEPARATOR)
591-
);
579+
$source = $this->_getSourceAdapter($sourceFile);
592580
} catch (\Exception $e) {
593581
$this->_varDirectory->delete($this->_varDirectory->getRelativePath($sourceFile));
594582
throw new LocalizedException(__($e->getMessage()));

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

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,13 @@ public function create($source, $directory = null, $options = null): AbstractSou
5959
__('\'%1\' file extension is not supported', $type)
6060
);
6161
}
62-
$data = [];
63-
$data['file'] = $source;
64-
$data['directory'] = $directory;
65-
if ($type === 'Csv') {
66-
$data['delimiter'] = $options;
67-
} else {
68-
$data['options'] = $options;
69-
}
7062
return $this->objectManager->create(
7163
$adapterClass,
72-
$data
64+
[
65+
'file' => $source,
66+
'directory' => $directory,
67+
'options' => $options
68+
]
7369
);
7470
}
7571
}

0 commit comments

Comments
 (0)