Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions app/code/Magento/CatalogImportExport/Model/Import/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Magento\Catalog\Model\Product\Visibility;
use Magento\CatalogImportExport\Model\Import\Product\RowValidatorInterface as ValidatorInterface;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Filesystem;
use Magento\Framework\Model\ResourceModel\Db\ObjectRelationProcessor;
use Magento\Framework\Model\ResourceModel\Db\TransactionManagerInterface;
Expand Down Expand Up @@ -712,7 +713,7 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
* @param \Magento\CatalogInventory\Model\Spi\StockStateProviderInterface $stockStateProvider
* @param \Magento\Catalog\Helper\Data $catalogData
* @param \Magento\ImportExport\Model\Import\Config $importConfig
* @param Proxy\Product\ResourceFactory $resourceFactory
* @param Proxy\Product\ResourceModelFactory $resourceFactory
* @param Product\OptionFactory $optionFactory
* @param \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory $setColFactory
* @param Product\Type\Factory $productTypeFactory
Expand Down Expand Up @@ -1084,12 +1085,12 @@ protected function _initTypeModels()
$params = [$this, $productTypeName];
if (!($model = $this->_productTypeFactory->create($productTypeConfig['model'], ['params' => $params]))
) {
throw new \Magento\Framework\Exception\LocalizedException(
throw new LocalizedException(
__('Entity type model \'%1\' is not found', $productTypeConfig['model'])
);
}
if (!$model instanceof \Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType) {
throw new \Magento\Framework\Exception\LocalizedException(
throw new LocalizedException(
__(
'Entity type model must be an instance of '
. \Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType::class
Expand Down Expand Up @@ -1551,6 +1552,7 @@ public function getImagesFromRow(array $rowData)
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
* @throws \Magento\Framework\Exception\LocalizedException
*/
protected function _saveProducts()
{
Expand Down Expand Up @@ -1611,7 +1613,7 @@ protected function _saveProducts()

// wrong attribute_set_code was received
if (!$attributeSetId) {
throw new \Magento\Framework\Exception\LocalizedException(
throw new LocalizedException(
__(
'Wrong attribute set code "%1", please correct it and try again.',
$rowData['attribute_set_code']
Expand Down Expand Up @@ -1814,7 +1816,7 @@ protected function _saveProducts()
) {
$attrValue = $this->dateTime->formatDate($attrValue, false);
} elseif ('datetime' == $attribute->getBackendType() && strtotime($attrValue)) {
$attrValue = $this->dateTime->gmDate(
$attrValue = gmdate(
'Y-m-d H:i:s',
$this->_localeDate->date($attrValue)->getTimestamp()
);
Expand Down Expand Up @@ -1998,7 +2000,7 @@ protected function _getUploader()
}

if (!$this->_fileUploader->setTmpDir($tmpPath)) {
throw new \Magento\Framework\Exception\LocalizedException(
throw new LocalizedException(
__('File directory \'%1\' is not readable.', $tmpPath)
);
}
Expand All @@ -2007,7 +2009,7 @@ protected function _getUploader()

$this->_mediaDirectory->create($destinationPath);
if (!$this->_fileUploader->setDestDir($destinationPath)) {
throw new \Magento\Framework\Exception\LocalizedException(
throw new LocalizedException(
__('File directory \'%1\' is not writable.', $destinationPath)
);
}
Expand All @@ -2029,6 +2031,8 @@ public function getUploader()
* Return a new file name if the same file is already exists.
*
* @param string $fileName
* @param bool $renameFileOff [optional] boolean to pass. Default is false
* which will set not to rename the file after import.
* @return string
*/
protected function uploadMediaFiles($fileName, $renameFileOff = false)
Expand Down Expand Up @@ -2237,7 +2241,7 @@ protected function _saveStockItem()
$stockItemDo->setData($row);
$row['is_in_stock'] = $this->stockStateProvider->verifyStock($stockItemDo);
if ($this->stockStateProvider->verifyNotification($stockItemDo)) {
$row['low_stock_date'] = $this->dateTime->gmDate(
$row['low_stock_date'] = gmdate(
'Y-m-d H:i:s',
(new \DateTime())->getTimestamp()
);
Expand Down Expand Up @@ -2755,7 +2759,7 @@ private function _customFieldsMapping($rowData)
/**
* Validate data rows and save bunches to DB
*
* @return $this
* @return $this|\Magento\ImportExport\Model\Import\Entity\AbstractEntity
*/
protected function _saveValidatedBunches()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

use Magento\Framework\App\ObjectManager;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Serialize\Serializer\Json;
use Magento\ImportExport\Model\Import\AbstractSource;
use Magento\ImportExport\Model\Import as ImportExport;
Expand Down Expand Up @@ -310,7 +311,7 @@ public function __construct(
protected function _getSource()
{
if (!$this->_source) {
throw new \Magento\Framework\Exception\LocalizedException(__('Please specify a source.'));
throw new LocalizedException(__('Please specify a source.'));
}
return $this->_source;
}
Expand Down Expand Up @@ -378,7 +379,7 @@ protected function addErrors($code, $errors)
/**
* Validate data rows and save bunches to DB.
*
* @return $this|void
* @return $this
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
protected function _saveValidatedBunches()
Expand Down Expand Up @@ -548,11 +549,11 @@ public function getBehavior()
if (!isset(
$this->_parameters['behavior']
) ||
$this->_parameters['behavior'] != \Magento\ImportExport\Model\Import::BEHAVIOR_APPEND &&
$this->_parameters['behavior'] != \Magento\ImportExport\Model\Import::BEHAVIOR_REPLACE &&
$this->_parameters['behavior'] != \Magento\ImportExport\Model\Import::BEHAVIOR_DELETE
$this->_parameters['behavior'] != ImportExport::BEHAVIOR_APPEND &&
$this->_parameters['behavior'] != ImportExport::BEHAVIOR_REPLACE &&
$this->_parameters['behavior'] != ImportExport::BEHAVIOR_DELETE
) {
return \Magento\ImportExport\Model\Import::getDefaultBehavior();
return ImportExport::getDefaultBehavior();
}
return $this->_parameters['behavior'];
}
Expand Down Expand Up @@ -604,7 +605,7 @@ public function getProcessedRowsCount()
public function getSource()
{
if (!$this->_source) {
throw new \Magento\Framework\Exception\LocalizedException(__('The source is not set.'));
throw new LocalizedException(__('The source is not set.'));
}
return $this->_source;
}
Expand Down Expand Up @@ -879,7 +880,7 @@ public function getValidColumnNames()
protected function getMetadataPool()
{
if (!$this->metadataPool) {
$this->metadataPool = \Magento\Framework\App\ObjectManager::getInstance()
$this->metadataPool = ObjectManager::getInstance()
->get(\Magento\Framework\EntityManager\MetadataPool::class);
}
return $this->metadataPool;
Expand Down