Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit ac7df33

Browse files
Merge forwardport of magento/magento2#12257 to 2.3-develop branch
Applied pull request patch https://github.com/magento/magento2/pull/12257.patch (created by @KarlDeux) based on commit(s): 1. f936604 2. 3ce246d 3. 8f1aa87 4. 41a43c1 5. 19de842 6. dc22a82 7. 820c097
2 parents a2b9fab + 90f9d95 commit ac7df33

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

app/code/Magento/CatalogImportExport/Model/Import/Product.php

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
use Magento\CatalogImportExport\Model\Import\Product\ImageTypeProcessor;
1212
use Magento\CatalogImportExport\Model\Import\Product\RowValidatorInterface as ValidatorInterface;
1313
use Magento\Framework\App\Filesystem\DirectoryList;
14+
use Magento\Framework\App\ObjectManager;
15+
use Magento\Framework\Exception\LocalizedException;
1416
use Magento\Framework\Filesystem;
1517
use Magento\Framework\Model\ResourceModel\Db\ObjectRelationProcessor;
1618
use Magento\Framework\Model\ResourceModel\Db\TransactionManagerInterface;
@@ -729,7 +731,7 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
729731
* @param \Magento\CatalogInventory\Model\Spi\StockStateProviderInterface $stockStateProvider
730732
* @param \Magento\Catalog\Helper\Data $catalogData
731733
* @param \Magento\ImportExport\Model\Import\Config $importConfig
732-
* @param Proxy\Product\ResourceFactory $resourceFactory
734+
* @param Proxy\Product\ResourceModelFactory $resourceFactory
733735
* @param Product\OptionFactory $optionFactory
734736
* @param \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory $setColFactory
735737
* @param Product\Type\Factory $productTypeFactory
@@ -1121,12 +1123,12 @@ protected function _initTypeModels()
11211123
$params = [$this, $productTypeName];
11221124
if (!($model = $this->_productTypeFactory->create($productTypeConfig['model'], ['params' => $params]))
11231125
) {
1124-
throw new \Magento\Framework\Exception\LocalizedException(
1126+
throw new LocalizedException(
11251127
__('Entity type model \'%1\' is not found', $productTypeConfig['model'])
11261128
);
11271129
}
11281130
if (!$model instanceof \Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType) {
1129-
throw new \Magento\Framework\Exception\LocalizedException(
1131+
throw new LocalizedException(
11301132
__(
11311133
'Entity type model must be an instance of '
11321134
. \Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType::class
@@ -1549,6 +1551,7 @@ public function getImagesFromRow(array $rowData)
15491551
* @SuppressWarnings(PHPMD.NPathComplexity)
15501552
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
15511553
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
1554+
* @throws LocalizedException
15521555
*/
15531556
protected function _saveProducts()
15541557
{
@@ -1609,7 +1612,7 @@ protected function _saveProducts()
16091612

16101613
// wrong attribute_set_code was received
16111614
if (!$attributeSetId) {
1612-
throw new \Magento\Framework\Exception\LocalizedException(
1615+
throw new LocalizedException(
16131616
__(
16141617
'Wrong attribute set code "%1", please correct it and try again.',
16151618
$rowData['attribute_set_code']
@@ -1822,7 +1825,7 @@ protected function _saveProducts()
18221825
) {
18231826
$attrValue = $this->dateTime->formatDate($attrValue, false);
18241827
} elseif ('datetime' == $attribute->getBackendType() && strtotime($attrValue)) {
1825-
$attrValue = $this->dateTime->gmDate(
1828+
$attrValue = gmdate(
18261829
'Y-m-d H:i:s',
18271830
$this->_localeDate->date($attrValue)->getTimestamp()
18281831
);
@@ -2004,7 +2007,7 @@ protected function _getUploader()
20042007
}
20052008

20062009
if (!$this->_fileUploader->setTmpDir($tmpPath)) {
2007-
throw new \Magento\Framework\Exception\LocalizedException(
2010+
throw new LocalizedException(
20082011
__('File directory \'%1\' is not readable.', $tmpPath)
20092012
);
20102013
}
@@ -2013,7 +2016,7 @@ protected function _getUploader()
20132016

20142017
$this->_mediaDirectory->create($destinationPath);
20152018
if (!$this->_fileUploader->setDestDir($destinationPath)) {
2016-
throw new \Magento\Framework\Exception\LocalizedException(
2019+
throw new LocalizedException(
20172020
__('File directory \'%1\' is not writable.', $destinationPath)
20182021
);
20192022
}
@@ -2035,6 +2038,8 @@ public function getUploader()
20352038
* Return a new file name if the same file is already exists.
20362039
*
20372040
* @param string $fileName
2041+
* @param bool $renameFileOff [optional] boolean to pass.
2042+
* Default is false which will set not to rename the file after import.
20382043
* @return string
20392044
*/
20402045
protected function uploadMediaFiles($fileName, $renameFileOff = false)
@@ -2162,7 +2167,7 @@ protected function _saveStockItem()
21622167
$stockItemDo->setData($row);
21632168
$row['is_in_stock'] = $this->stockStateProvider->verifyStock($stockItemDo);
21642169
if ($this->stockStateProvider->verifyNotification($stockItemDo)) {
2165-
$row['low_stock_date'] = $this->dateTime->gmDate(
2170+
$row['low_stock_date'] = gmdate(
21662171
'Y-m-d H:i:s',
21672172
(new \DateTime())->getTimestamp()
21682173
);
@@ -2678,7 +2683,7 @@ private function _customFieldsMapping($rowData)
26782683
/**
26792684
* Validate data rows and save bunches to DB
26802685
*
2681-
* @return $this
2686+
* @return $this|AbstractEntity
26822687
*/
26832688
protected function _saveValidatedBunches()
26842689
{

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
use Magento\Framework\App\ObjectManager;
99
use Magento\Framework\App\ResourceConnection;
10+
use Magento\Framework\Exception\LocalizedException;
1011
use Magento\Framework\Serialize\Serializer\Json;
1112
use Magento\ImportExport\Model\Import\AbstractSource;
1213
use Magento\ImportExport\Model\Import as ImportExport;
@@ -310,7 +311,7 @@ public function __construct(
310311
protected function _getSource()
311312
{
312313
if (!$this->_source) {
313-
throw new \Magento\Framework\Exception\LocalizedException(__('Please specify a source.'));
314+
throw new LocalizedException(__('Please specify a source.'));
314315
}
315316
return $this->_source;
316317
}
@@ -378,7 +379,7 @@ protected function addErrors($code, $errors)
378379
/**
379380
* Validate data rows and save bunches to DB.
380381
*
381-
* @return $this|void
382+
* @return $this
382383
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
383384
*/
384385
protected function _saveValidatedBunches()
@@ -548,11 +549,11 @@ public function getBehavior()
548549
if (!isset(
549550
$this->_parameters['behavior']
550551
) ||
551-
$this->_parameters['behavior'] != \Magento\ImportExport\Model\Import::BEHAVIOR_APPEND &&
552-
$this->_parameters['behavior'] != \Magento\ImportExport\Model\Import::BEHAVIOR_REPLACE &&
553-
$this->_parameters['behavior'] != \Magento\ImportExport\Model\Import::BEHAVIOR_DELETE
552+
$this->_parameters['behavior'] != ImportExport::BEHAVIOR_APPEND &&
553+
$this->_parameters['behavior'] != ImportExport::BEHAVIOR_REPLACE &&
554+
$this->_parameters['behavior'] != ImportExport::BEHAVIOR_DELETE
554555
) {
555-
return \Magento\ImportExport\Model\Import::getDefaultBehavior();
556+
return ImportExport::getDefaultBehavior();
556557
}
557558
return $this->_parameters['behavior'];
558559
}
@@ -604,7 +605,7 @@ public function getProcessedRowsCount()
604605
public function getSource()
605606
{
606607
if (!$this->_source) {
607-
throw new \Magento\Framework\Exception\LocalizedException(__('The source is not set.'));
608+
throw new LocalizedException(__('The source is not set.'));
608609
}
609610
return $this->_source;
610611
}
@@ -879,7 +880,7 @@ public function getValidColumnNames()
879880
protected function getMetadataPool()
880881
{
881882
if (!$this->metadataPool) {
882-
$this->metadataPool = \Magento\Framework\App\ObjectManager::getInstance()
883+
$this->metadataPool = ObjectManager::getInstance()
883884
->get(\Magento\Framework\EntityManager\MetadataPool::class);
884885
}
885886
return $this->metadataPool;

0 commit comments

Comments
 (0)