diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product.php b/app/code/Magento/CatalogImportExport/Model/Import/Product.php index 5f4a512ec34de..d383c84876421 100644 --- a/app/code/Magento/CatalogImportExport/Model/Import/Product.php +++ b/app/code/Magento/CatalogImportExport/Model/Import/Product.php @@ -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; @@ -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 @@ -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 @@ -1551,6 +1552,7 @@ public function getImagesFromRow(array $rowData) * @SuppressWarnings(PHPMD.NPathComplexity) * @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.UnusedLocalVariable) + * @throws LocalizedException */ protected function _saveProducts() { @@ -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'] @@ -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) ); } @@ -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) ); } @@ -2029,6 +2031,7 @@ public function getUploader() * Return a new file name if the same file is already exists. * * @param string $fileName + * @param bool $renameFileOff * @return string */ protected function uploadMediaFiles($fileName, $renameFileOff = false) @@ -2753,9 +2756,7 @@ private function _customFieldsMapping($rowData) } /** - * Validate data rows and save bunches to DB - * - * @return $this + * {@inheritdoc} */ protected function _saveValidatedBunches() { diff --git a/app/code/Magento/ImportExport/Model/Import/Entity/AbstractEntity.php b/app/code/Magento/ImportExport/Model/Import/Entity/AbstractEntity.php index c61292f7c34f7..e7883693fbe74 100644 --- a/app/code/Magento/ImportExport/Model/Import/Entity/AbstractEntity.php +++ b/app/code/Magento/ImportExport/Model/Import/Entity/AbstractEntity.php @@ -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; @@ -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; } @@ -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() @@ -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']; } @@ -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; } @@ -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;