Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 9e95852

Browse files
MAGETWO-87615: [EngCom Team] Batch 34. Forwardports to 2.3-develop #1362
2 parents ec39184 + f26bda7 commit 9e95852

File tree

14 files changed

+638
-552
lines changed

14 files changed

+638
-552
lines changed

app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/AbstractTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,13 @@ public function testWalkAttributes()
4444

4545
$code = 'test_attr';
4646
$set = 10;
47+
$storeId = 100;
4748

4849
$object = $this->createPartialMock(\Magento\Catalog\Model\Product::class, ['__wakeup']);
4950

5051
$object->setData('test_attr', 'test_attr');
5152
$object->setData('attribute_set_id', $set);
53+
$object->setData('store_id', $storeId);
5254

5355
$entityType = new \Magento\Framework\DataObject();
5456
$entityType->setEntityTypeCode('test');

app/code/Magento/CatalogImportExport/Model/Import/Product.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
use Magento\CatalogImportExport\Model\Import\Product\ImageTypeProcessor;
1212
use Magento\CatalogImportExport\Model\Import\Product\RowValidatorInterface as ValidatorInterface;
1313
use Magento\Framework\App\Filesystem\DirectoryList;
14+
use Magento\Framework\App\ObjectManager;
15+
use Magento\Framework\Exception\LocalizedException;
1416
use Magento\Framework\Filesystem;
1517
use Magento\Framework\Model\ResourceModel\Db\ObjectRelationProcessor;
1618
use Magento\Framework\Model\ResourceModel\Db\TransactionManagerInterface;
@@ -20,7 +22,6 @@
2022
use Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingError;
2123
use Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregatorInterface;
2224
use Magento\Store\Model\Store;
23-
use Magento\Framework\App\ObjectManager;
2425

2526
/**
2627
* Import entity product model
@@ -729,7 +730,7 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
729730
* @param \Magento\CatalogInventory\Model\Spi\StockStateProviderInterface $stockStateProvider
730731
* @param \Magento\Catalog\Helper\Data $catalogData
731732
* @param \Magento\ImportExport\Model\Import\Config $importConfig
732-
* @param Proxy\Product\ResourceFactory $resourceFactory
733+
* @param Proxy\Product\ResourceModelFactory $resourceFactory
733734
* @param Product\OptionFactory $optionFactory
734735
* @param \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory $setColFactory
735736
* @param Product\Type\Factory $productTypeFactory
@@ -1121,12 +1122,12 @@ protected function _initTypeModels()
11211122
$params = [$this, $productTypeName];
11221123
if (!($model = $this->_productTypeFactory->create($productTypeConfig['model'], ['params' => $params]))
11231124
) {
1124-
throw new \Magento\Framework\Exception\LocalizedException(
1125+
throw new LocalizedException(
11251126
__('Entity type model \'%1\' is not found', $productTypeConfig['model'])
11261127
);
11271128
}
11281129
if (!$model instanceof \Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType) {
1129-
throw new \Magento\Framework\Exception\LocalizedException(
1130+
throw new LocalizedException(
11301131
__(
11311132
'Entity type model must be an instance of '
11321133
. \Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType::class
@@ -1549,6 +1550,7 @@ public function getImagesFromRow(array $rowData)
15491550
* @SuppressWarnings(PHPMD.NPathComplexity)
15501551
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
15511552
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
1553+
* @throws LocalizedException
15521554
*/
15531555
protected function _saveProducts()
15541556
{
@@ -1609,7 +1611,7 @@ protected function _saveProducts()
16091611

16101612
// wrong attribute_set_code was received
16111613
if (!$attributeSetId) {
1612-
throw new \Magento\Framework\Exception\LocalizedException(
1614+
throw new LocalizedException(
16131615
__(
16141616
'Wrong attribute set code "%1", please correct it and try again.',
16151617
$rowData['attribute_set_code']
@@ -1822,7 +1824,7 @@ protected function _saveProducts()
18221824
) {
18231825
$attrValue = $this->dateTime->formatDate($attrValue, false);
18241826
} elseif ('datetime' == $attribute->getBackendType() && strtotime($attrValue)) {
1825-
$attrValue = $this->dateTime->gmDate(
1827+
$attrValue = gmdate(
18261828
'Y-m-d H:i:s',
18271829
$this->_localeDate->date($attrValue)->getTimestamp()
18281830
);
@@ -2004,7 +2006,7 @@ protected function _getUploader()
20042006
}
20052007

20062008
if (!$this->_fileUploader->setTmpDir($tmpPath)) {
2007-
throw new \Magento\Framework\Exception\LocalizedException(
2009+
throw new LocalizedException(
20082010
__('File directory \'%1\' is not readable.', $tmpPath)
20092011
);
20102012
}
@@ -2013,7 +2015,7 @@ protected function _getUploader()
20132015

20142016
$this->_mediaDirectory->create($destinationPath);
20152017
if (!$this->_fileUploader->setDestDir($destinationPath)) {
2016-
throw new \Magento\Framework\Exception\LocalizedException(
2018+
throw new LocalizedException(
20172019
__('File directory \'%1\' is not writable.', $destinationPath)
20182020
);
20192021
}
@@ -2035,6 +2037,8 @@ public function getUploader()
20352037
* Return a new file name if the same file is already exists.
20362038
*
20372039
* @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.
20382042
* @return string
20392043
*/
20402044
protected function uploadMediaFiles($fileName, $renameFileOff = false)
@@ -2162,7 +2166,7 @@ protected function _saveStockItem()
21622166
$stockItemDo->setData($row);
21632167
$row['is_in_stock'] = $this->stockStateProvider->verifyStock($stockItemDo);
21642168
if ($this->stockStateProvider->verifyNotification($stockItemDo)) {
2165-
$row['low_stock_date'] = $this->dateTime->gmDate(
2169+
$row['low_stock_date'] = gmdate(
21662170
'Y-m-d H:i:s',
21672171
(new \DateTime())->getTimestamp()
21682172
);
@@ -2678,7 +2682,7 @@ private function _customFieldsMapping($rowData)
26782682
/**
26792683
* Validate data rows and save bunches to DB
26802684
*
2681-
* @return $this
2685+
* @return $this|AbstractEntity
26822686
*/
26832687
protected function _saveValidatedBunches()
26842688
{

0 commit comments

Comments
 (0)