9
9
use Magento \CatalogImportExport \Model \Import \Product \RowValidatorInterface as ValidatorInterface ;
10
10
use Magento \Framework \App \Filesystem \DirectoryList ;
11
11
use Magento \Framework \App \ObjectManager ;
12
+ use Magento \Framework \Exception \LocalizedException ;
12
13
use Magento \Framework \Model \ResourceModel \Db \ObjectRelationProcessor ;
13
14
use Magento \Framework \Model \ResourceModel \Db \TransactionManagerInterface ;
14
15
use Magento \Framework \Stdlib \DateTime ;
@@ -714,7 +715,7 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
714
715
* @param \Magento\CatalogInventory\Model\Spi\StockStateProviderInterface $stockStateProvider
715
716
* @param \Magento\Catalog\Helper\Data $catalogData
716
717
* @param \Magento\ImportExport\Model\Import\Config $importConfig
717
- * @param Proxy\Product\ResourceFactory $resourceFactory
718
+ * @param Proxy\Product\ResourceModelFactory $resourceFactory
718
719
* @param Product\OptionFactory $optionFactory
719
720
* @param \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory $setColFactory
720
721
* @param Product\Type\Factory $productTypeFactory
@@ -1089,12 +1090,12 @@ protected function _initTypeModels()
1089
1090
$ params = [$ this , $ productTypeName ];
1090
1091
if (!($ model = $ this ->_productTypeFactory ->create ($ productTypeConfig ['model ' ], ['params ' => $ params ]))
1091
1092
) {
1092
- throw new \ Magento \ Framework \ Exception \ LocalizedException (
1093
+ throw new LocalizedException (
1093
1094
__ ('Entity type model \'%1 \' is not found ' , $ productTypeConfig ['model ' ])
1094
1095
);
1095
1096
}
1096
1097
if (!$ model instanceof \Magento \CatalogImportExport \Model \Import \Product \Type \AbstractType) {
1097
- throw new \ Magento \ Framework \ Exception \ LocalizedException (
1098
+ throw new LocalizedException (
1098
1099
__ (
1099
1100
'Entity type model must be an instance of '
1100
1101
. \Magento \CatalogImportExport \Model \Import \Product \Type \AbstractType::class
@@ -1561,6 +1562,7 @@ public function getImagesFromRow(array $rowData)
1561
1562
* @SuppressWarnings(PHPMD.NPathComplexity)
1562
1563
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
1563
1564
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
1565
+ * @throws LocalizedException
1564
1566
*/
1565
1567
protected function _saveProducts ()
1566
1568
{
@@ -1621,7 +1623,7 @@ protected function _saveProducts()
1621
1623
1622
1624
// wrong attribute_set_code was received
1623
1625
if (!$ attributeSetId ) {
1624
- throw new \ Magento \ Framework \ Exception \ LocalizedException (
1626
+ throw new LocalizedException (
1625
1627
__ (
1626
1628
'Wrong attribute set code "%1", please correct it and try again. ' ,
1627
1629
$ rowData ['attribute_set_code ' ]
@@ -1826,7 +1828,7 @@ protected function _saveProducts()
1826
1828
) {
1827
1829
$ attrValue = $ this ->dateTime ->formatDate ($ attrValue , false );
1828
1830
} elseif ('datetime ' == $ attribute ->getBackendType () && strtotime ($ attrValue )) {
1829
- $ attrValue = $ this -> dateTime -> gmDate (
1831
+ $ attrValue = gmdate (
1830
1832
'Y-m-d H:i:s ' ,
1831
1833
$ this ->_localeDate ->date ($ attrValue )->getTimestamp ()
1832
1834
);
@@ -2008,7 +2010,7 @@ protected function _getUploader()
2008
2010
}
2009
2011
2010
2012
if (!$ this ->_fileUploader ->setTmpDir ($ tmpPath )) {
2011
- throw new \ Magento \ Framework \ Exception \ LocalizedException (
2013
+ throw new LocalizedException (
2012
2014
__ ('File directory \'%1 \' is not readable. ' , $ tmpPath )
2013
2015
);
2014
2016
}
@@ -2017,7 +2019,7 @@ protected function _getUploader()
2017
2019
2018
2020
$ this ->_mediaDirectory ->create ($ destinationPath );
2019
2021
if (!$ this ->_fileUploader ->setDestDir ($ destinationPath )) {
2020
- throw new \ Magento \ Framework \ Exception \ LocalizedException (
2022
+ throw new LocalizedException (
2021
2023
__ ('File directory \'%1 \' is not writable. ' , $ destinationPath )
2022
2024
);
2023
2025
}
@@ -2039,6 +2041,8 @@ public function getUploader()
2039
2041
* Return a new file name if the same file is already exists.
2040
2042
*
2041
2043
* @param string $fileName
2044
+ * @param bool $renameFileOff [optional] boolean to pass.
2045
+ * Default is false which will set not to rename the file after import.
2042
2046
* @return string
2043
2047
*/
2044
2048
protected function uploadMediaFiles ($ fileName , $ renameFileOff = false )
@@ -2247,7 +2251,7 @@ protected function _saveStockItem()
2247
2251
$ stockItemDo ->setData ($ row );
2248
2252
$ row ['is_in_stock ' ] = $ this ->stockStateProvider ->verifyStock ($ stockItemDo );
2249
2253
if ($ this ->stockStateProvider ->verifyNotification ($ stockItemDo )) {
2250
- $ row ['low_stock_date ' ] = $ this -> dateTime -> gmDate (
2254
+ $ row ['low_stock_date ' ] = gmdate (
2251
2255
'Y-m-d H:i:s ' ,
2252
2256
(new \DateTime ())->getTimestamp ()
2253
2257
);
@@ -2763,7 +2767,7 @@ private function _customFieldsMapping($rowData)
2763
2767
/**
2764
2768
* Validate data rows and save bunches to DB
2765
2769
*
2766
- * @return $this
2770
+ * @return $this|AbstractEntity
2767
2771
*/
2768
2772
protected function _saveValidatedBunches ()
2769
2773
{
0 commit comments