Skip to content

Commit

Permalink
Merge forwardport of #12257 to 2.3-develop branch
Browse files Browse the repository at this point in the history
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
  • Loading branch information
magento-engcom-team authored Feb 7, 2018
2 parents a2b9fab + 90f9d95 commit ac7df33
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
23 changes: 14 additions & 9 deletions app/code/Magento/CatalogImportExport/Model/Import/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
use Magento\CatalogImportExport\Model\Import\Product\ImageTypeProcessor;
use Magento\CatalogImportExport\Model\Import\Product\RowValidatorInterface as ValidatorInterface;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\App\ObjectManager;
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 @@ -729,7 +731,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 @@ -1121,12 +1123,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 @@ -1549,6 +1551,7 @@ public function getImagesFromRow(array $rowData)
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
* @throws LocalizedException
*/
protected function _saveProducts()
{
Expand Down Expand Up @@ -1609,7 +1612,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 @@ -1822,7 +1825,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 @@ -2004,7 +2007,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 @@ -2013,7 +2016,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 @@ -2035,6 +2038,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 @@ -2162,7 +2167,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 @@ -2678,7 +2683,7 @@ private function _customFieldsMapping($rowData)
/**
* Validate data rows and save bunches to DB
*
* @return $this
* @return $this|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

0 comments on commit ac7df33

Please sign in to comment.