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