9
9
use Magento \Catalog \Model \Product \Visibility ;
10
10
use Magento \CatalogImportExport \Model \Import \Product \RowValidatorInterface as ValidatorInterface ;
11
11
use Magento \Framework \App \Filesystem \DirectoryList ;
12
+ use Magento \Framework \Exception \LocalizedException ;
12
13
use Magento \Framework \Filesystem ;
13
14
use Magento \Framework \Model \ResourceModel \Db \ObjectRelationProcessor ;
14
15
use Magento \Framework \Model \ResourceModel \Db \TransactionManagerInterface ;
@@ -712,7 +713,7 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
712
713
* @param \Magento\CatalogInventory\Model\Spi\StockStateProviderInterface $stockStateProvider
713
714
* @param \Magento\Catalog\Helper\Data $catalogData
714
715
* @param \Magento\ImportExport\Model\Import\Config $importConfig
715
- * @param Proxy\Product\ResourceFactory $resourceFactory
716
+ * @param Proxy\Product\ResourceModelFactory $resourceFactory
716
717
* @param Product\OptionFactory $optionFactory
717
718
* @param \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory $setColFactory
718
719
* @param Product\Type\Factory $productTypeFactory
@@ -1084,12 +1085,12 @@ protected function _initTypeModels()
1084
1085
$ params = [$ this , $ productTypeName ];
1085
1086
if (!($ model = $ this ->_productTypeFactory ->create ($ productTypeConfig ['model ' ], ['params ' => $ params ]))
1086
1087
) {
1087
- throw new \ Magento \ Framework \ Exception \ LocalizedException (
1088
+ throw new LocalizedException (
1088
1089
__ ('Entity type model \'%1 \' is not found ' , $ productTypeConfig ['model ' ])
1089
1090
);
1090
1091
}
1091
1092
if (!$ model instanceof \Magento \CatalogImportExport \Model \Import \Product \Type \AbstractType) {
1092
- throw new \ Magento \ Framework \ Exception \ LocalizedException (
1093
+ throw new LocalizedException (
1093
1094
__ (
1094
1095
'Entity type model must be an instance of '
1095
1096
. \Magento \CatalogImportExport \Model \Import \Product \Type \AbstractType::class
@@ -1551,6 +1552,7 @@ public function getImagesFromRow(array $rowData)
1551
1552
* @SuppressWarnings(PHPMD.NPathComplexity)
1552
1553
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
1553
1554
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
1555
+ * @throws \Magento\Framework\Exception\LocalizedException
1554
1556
*/
1555
1557
protected function _saveProducts ()
1556
1558
{
@@ -1611,7 +1613,7 @@ protected function _saveProducts()
1611
1613
1612
1614
// wrong attribute_set_code was received
1613
1615
if (!$ attributeSetId ) {
1614
- throw new \ Magento \ Framework \ Exception \ LocalizedException (
1616
+ throw new LocalizedException (
1615
1617
__ (
1616
1618
'Wrong attribute set code "%1", please correct it and try again. ' ,
1617
1619
$ rowData ['attribute_set_code ' ]
@@ -1814,7 +1816,7 @@ protected function _saveProducts()
1814
1816
) {
1815
1817
$ attrValue = $ this ->dateTime ->formatDate ($ attrValue , false );
1816
1818
} elseif ('datetime ' == $ attribute ->getBackendType () && strtotime ($ attrValue )) {
1817
- $ attrValue = $ this -> dateTime -> gmDate (
1819
+ $ attrValue = gmdate (
1818
1820
'Y-m-d H:i:s ' ,
1819
1821
$ this ->_localeDate ->date ($ attrValue )->getTimestamp ()
1820
1822
);
@@ -1998,7 +2000,7 @@ protected function _getUploader()
1998
2000
}
1999
2001
2000
2002
if (!$ this ->_fileUploader ->setTmpDir ($ tmpPath )) {
2001
- throw new \ Magento \ Framework \ Exception \ LocalizedException (
2003
+ throw new LocalizedException (
2002
2004
__ ('File directory \'%1 \' is not readable. ' , $ tmpPath )
2003
2005
);
2004
2006
}
@@ -2007,7 +2009,7 @@ protected function _getUploader()
2007
2009
2008
2010
$ this ->_mediaDirectory ->create ($ destinationPath );
2009
2011
if (!$ this ->_fileUploader ->setDestDir ($ destinationPath )) {
2010
- throw new \ Magento \ Framework \ Exception \ LocalizedException (
2012
+ throw new LocalizedException (
2011
2013
__ ('File directory \'%1 \' is not writable. ' , $ destinationPath )
2012
2014
);
2013
2015
}
@@ -2029,6 +2031,8 @@ public function getUploader()
2029
2031
* Return a new file name if the same file is already exists.
2030
2032
*
2031
2033
* @param string $fileName
2034
+ * @param bool $renameFileOff [optional] boolean to pass. Default is false
2035
+ * which will set not to rename the file after import.
2032
2036
* @return string
2033
2037
*/
2034
2038
protected function uploadMediaFiles ($ fileName , $ renameFileOff = false )
@@ -2237,7 +2241,7 @@ protected function _saveStockItem()
2237
2241
$ stockItemDo ->setData ($ row );
2238
2242
$ row ['is_in_stock ' ] = $ this ->stockStateProvider ->verifyStock ($ stockItemDo );
2239
2243
if ($ this ->stockStateProvider ->verifyNotification ($ stockItemDo )) {
2240
- $ row ['low_stock_date ' ] = $ this -> dateTime -> gmDate (
2244
+ $ row ['low_stock_date ' ] = gmdate (
2241
2245
'Y-m-d H:i:s ' ,
2242
2246
(new \DateTime ())->getTimestamp ()
2243
2247
);
@@ -2755,7 +2759,7 @@ private function _customFieldsMapping($rowData)
2755
2759
/**
2756
2760
* Validate data rows and save bunches to DB
2757
2761
*
2758
- * @return $this
2762
+ * @return $this|\Magento\ImportExport\Model\Import\Entity\AbstractEntity
2759
2763
*/
2760
2764
protected function _saveValidatedBunches ()
2761
2765
{
0 commit comments