11
11
use Magento \CatalogImportExport \Model \Import \Product \ImageTypeProcessor ;
12
12
use Magento \CatalogImportExport \Model \Import \Product \RowValidatorInterface as ValidatorInterface ;
13
13
use Magento \Framework \App \Filesystem \DirectoryList ;
14
+ use Magento \Framework \App \ObjectManager ;
15
+ use Magento \Framework \Exception \LocalizedException ;
14
16
use Magento \Framework \Filesystem ;
15
17
use Magento \Framework \Model \ResourceModel \Db \ObjectRelationProcessor ;
16
18
use Magento \Framework \Model \ResourceModel \Db \TransactionManagerInterface ;
20
22
use Magento \ImportExport \Model \Import \ErrorProcessing \ProcessingError ;
21
23
use Magento \ImportExport \Model \Import \ErrorProcessing \ProcessingErrorAggregatorInterface ;
22
24
use Magento \Store \Model \Store ;
23
- use Magento \Framework \App \ObjectManager ;
24
25
25
26
/**
26
27
* Import entity product model
@@ -729,7 +730,7 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
729
730
* @param \Magento\CatalogInventory\Model\Spi\StockStateProviderInterface $stockStateProvider
730
731
* @param \Magento\Catalog\Helper\Data $catalogData
731
732
* @param \Magento\ImportExport\Model\Import\Config $importConfig
732
- * @param Proxy\Product\ResourceFactory $resourceFactory
733
+ * @param Proxy\Product\ResourceModelFactory $resourceFactory
733
734
* @param Product\OptionFactory $optionFactory
734
735
* @param \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory $setColFactory
735
736
* @param Product\Type\Factory $productTypeFactory
@@ -1121,12 +1122,12 @@ protected function _initTypeModels()
1121
1122
$ params = [$ this , $ productTypeName ];
1122
1123
if (!($ model = $ this ->_productTypeFactory ->create ($ productTypeConfig ['model ' ], ['params ' => $ params ]))
1123
1124
) {
1124
- throw new \ Magento \ Framework \ Exception \ LocalizedException (
1125
+ throw new LocalizedException (
1125
1126
__ ('Entity type model \'%1 \' is not found ' , $ productTypeConfig ['model ' ])
1126
1127
);
1127
1128
}
1128
1129
if (!$ model instanceof \Magento \CatalogImportExport \Model \Import \Product \Type \AbstractType) {
1129
- throw new \ Magento \ Framework \ Exception \ LocalizedException (
1130
+ throw new LocalizedException (
1130
1131
__ (
1131
1132
'Entity type model must be an instance of '
1132
1133
. \Magento \CatalogImportExport \Model \Import \Product \Type \AbstractType::class
@@ -1549,6 +1550,7 @@ public function getImagesFromRow(array $rowData)
1549
1550
* @SuppressWarnings(PHPMD.NPathComplexity)
1550
1551
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
1551
1552
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
1553
+ * @throws LocalizedException
1552
1554
*/
1553
1555
protected function _saveProducts ()
1554
1556
{
@@ -1609,7 +1611,7 @@ protected function _saveProducts()
1609
1611
1610
1612
// wrong attribute_set_code was received
1611
1613
if (!$ attributeSetId ) {
1612
- throw new \ Magento \ Framework \ Exception \ LocalizedException (
1614
+ throw new LocalizedException (
1613
1615
__ (
1614
1616
'Wrong attribute set code "%1", please correct it and try again. ' ,
1615
1617
$ rowData ['attribute_set_code ' ]
@@ -1822,7 +1824,7 @@ protected function _saveProducts()
1822
1824
) {
1823
1825
$ attrValue = $ this ->dateTime ->formatDate ($ attrValue , false );
1824
1826
} elseif ('datetime ' == $ attribute ->getBackendType () && strtotime ($ attrValue )) {
1825
- $ attrValue = $ this -> dateTime -> gmDate (
1827
+ $ attrValue = gmdate (
1826
1828
'Y-m-d H:i:s ' ,
1827
1829
$ this ->_localeDate ->date ($ attrValue )->getTimestamp ()
1828
1830
);
@@ -2004,7 +2006,7 @@ protected function _getUploader()
2004
2006
}
2005
2007
2006
2008
if (!$ this ->_fileUploader ->setTmpDir ($ tmpPath )) {
2007
- throw new \ Magento \ Framework \ Exception \ LocalizedException (
2009
+ throw new LocalizedException (
2008
2010
__ ('File directory \'%1 \' is not readable. ' , $ tmpPath )
2009
2011
);
2010
2012
}
@@ -2013,7 +2015,7 @@ protected function _getUploader()
2013
2015
2014
2016
$ this ->_mediaDirectory ->create ($ destinationPath );
2015
2017
if (!$ this ->_fileUploader ->setDestDir ($ destinationPath )) {
2016
- throw new \ Magento \ Framework \ Exception \ LocalizedException (
2018
+ throw new LocalizedException (
2017
2019
__ ('File directory \'%1 \' is not writable. ' , $ destinationPath )
2018
2020
);
2019
2021
}
@@ -2035,6 +2037,8 @@ public function getUploader()
2035
2037
* Return a new file name if the same file is already exists.
2036
2038
*
2037
2039
* @param string $fileName
2040
+ * @param bool $renameFileOff [optional] boolean to pass.
2041
+ * Default is false which will set not to rename the file after import.
2038
2042
* @return string
2039
2043
*/
2040
2044
protected function uploadMediaFiles ($ fileName , $ renameFileOff = false )
@@ -2162,7 +2166,7 @@ protected function _saveStockItem()
2162
2166
$ stockItemDo ->setData ($ row );
2163
2167
$ row ['is_in_stock ' ] = $ this ->stockStateProvider ->verifyStock ($ stockItemDo );
2164
2168
if ($ this ->stockStateProvider ->verifyNotification ($ stockItemDo )) {
2165
- $ row ['low_stock_date ' ] = $ this -> dateTime -> gmDate (
2169
+ $ row ['low_stock_date ' ] = gmdate (
2166
2170
'Y-m-d H:i:s ' ,
2167
2171
(new \DateTime ())->getTimestamp ()
2168
2172
);
@@ -2678,7 +2682,7 @@ private function _customFieldsMapping($rowData)
2678
2682
/**
2679
2683
* Validate data rows and save bunches to DB
2680
2684
*
2681
- * @return $this
2685
+ * @return $this|AbstractEntity
2682
2686
*/
2683
2687
protected function _saveValidatedBunches ()
2684
2688
{
0 commit comments