Skip to content

Commit fadc581

Browse files
committed
Merge branch 'ACP2E-1813' of https://github.com/magento-l3/magento2ce into L3-PR-2023-06-23
2 parents ce4f831 + 84f5054 commit fadc581

File tree

5 files changed

+46
-25
lines changed

5 files changed

+46
-25
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ class Product extends AbstractEntity
307307
ValidatorInterface::ERROR_INVALID_VARIATIONS_CUSTOM_OPTIONS => 'Value for \'%s\' sub attribute in \'%s\' attribute contains incorrect value, acceptable values are: \'dropdown\', \'checkbox\', \'radio\', \'text\'',
308308
ValidatorInterface::ERROR_INVALID_MEDIA_URL_OR_PATH => 'Wrong URL/path used for attribute %s',
309309
ValidatorInterface::ERROR_MEDIA_PATH_NOT_ACCESSIBLE => 'Imported resource (image) does not exist in the local media storage',
310-
ValidatorInterface::ERROR_MEDIA_URL_NOT_ACCESSIBLE => 'Imported resource (image) could not be downloaded from external resource due to timeout or access permissions',
310+
ValidatorInterface::ERROR_MEDIA_URL_NOT_ACCESSIBLE => 'Imported resource (image: %s) at row %s could not be downloaded from external resource due to timeout or access permissions',
311311
ValidatorInterface::ERROR_INVALID_WEIGHT => 'Product weight is invalid',
312312
ValidatorInterface::ERROR_DUPLICATE_URL_KEY => 'Url key: \'%s\' was already generated for an item with the SKU: \'%s\'. You need to specify the unique URL key manually',
313313
ValidatorInterface::ERROR_DUPLICATE_MULTISELECT_VALUES => 'Value for multiselect attribute %s contains duplicated values',
@@ -1899,7 +1899,11 @@ private function saveProductMediaGalleryPhase(
18991899
ValidatorInterface::ERROR_MEDIA_URL_NOT_ACCESSIBLE,
19001900
$rowNum,
19011901
null,
1902-
null,
1902+
sprintf(
1903+
$this->_messageTemplates[ValidatorInterface::ERROR_MEDIA_URL_NOT_ACCESSIBLE],
1904+
$columnImage,
1905+
$rowNum
1906+
),
19031907
ProcessingError::ERROR_LEVEL_NOT_CRITICAL
19041908
);
19051909
}

app/code/Magento/ImportExport/Model/Import.php

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -521,14 +521,8 @@ public function importSource()
521521
*/
522522
private function importSourceCallback()
523523
{
524-
$ids = $this->_getEntityAdapter()->getIds();
525-
if (empty($ids)) {
526-
$idsFromPostData = $this->getData(self::FIELD_IMPORT_IDS);
527-
if (null !== $idsFromPostData && '' !== $idsFromPostData) {
528-
$ids = explode(",", $idsFromPostData);
529-
$this->_getEntityAdapter()->setIds($ids);
530-
}
531-
}
524+
$ids = $this->getImportIds();
525+
$this->_getEntityAdapter()->setIds($ids);
532526
$this->setData('entity', $this->getDataSourceModel()->getEntityTypeCode($ids));
533527
$this->setData('behavior', $this->getDataSourceModel()->getBehavior($ids));
534528

@@ -560,18 +554,21 @@ private function importSourceCallback()
560554
$this->getDataSourceModel()->markProcessedBunches($ids);
561555

562556
if ($result) {
563-
$this->addLogComment(
564-
[
565-
__(
566-
'Checked rows: %1, checked entities: %2, invalid rows: %3, total errors: %4',
567-
$this->getProcessedRowsCount(),
568-
$this->getProcessedEntitiesCount(),
569-
$this->getErrorAggregator()->getInvalidRowsCount(),
570-
$this->getErrorAggregator()->getErrorsCount()
571-
),
572-
__('The import was successful.'),
573-
]
574-
);
557+
$logComments = [
558+
__(
559+
'Checked rows: %1, checked entities: %2, invalid rows: %3, total errors: %4',
560+
$this->getProcessedRowsCount(),
561+
$this->getProcessedEntitiesCount(),
562+
$this->getErrorAggregator()->getInvalidRowsCount(),
563+
$this->getErrorAggregator()->getErrorsCount()
564+
)
565+
];
566+
foreach ($this->getErrorAggregator()->getAllErrors() as $error) {
567+
$logComments[] = $error->getErrorMessage();
568+
}
569+
$logComments[] = $this->getForceImport() == '0' && $this->getErrorAggregator()->getErrorsCount() > 0 ?
570+
__('The import was not successful.') : __('The import was successful.');
571+
$this->addLogComment($logComments);
575572
$this->importHistoryModel->updateReport($this, true);
576573
} else {
577574
$this->importHistoryModel->invalidateReport($this);
@@ -580,6 +577,25 @@ private function importSourceCallback()
580577
return $result;
581578
}
582579

580+
/**
581+
* Get entity import ids
582+
*
583+
* @return array
584+
* @throws LocalizedException
585+
*/
586+
private function getImportIds(): array
587+
{
588+
$ids = $this->_getEntityAdapter()->getIds();
589+
if (empty($ids)) {
590+
$idsFromPostData = $this->getData(self::FIELD_IMPORT_IDS);
591+
if (null !== $idsFromPostData && '' !== $idsFromPostData) {
592+
$ids = explode(",", $idsFromPostData);
593+
}
594+
}
595+
596+
return $ids;
597+
}
598+
583599
/**
584600
* Process import.
585601
*

app/code/Magento/ImportExport/Test/Unit/Model/ImportTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ protected function setUp(): void
276276
'_getEntityAdapter'
277277
]
278278
)
279+
->addMethods(['getForceImport'])
279280
->getMock();
280281
$this->setPropertyValue($this->import, '_varDirectory', $this->_varDirectory);
281282
}
@@ -321,6 +322,8 @@ public function testImportSource()
321322
$this->import->expects($this->any())
322323
->method('_getEntityAdapter')
323324
->willReturn($this->_entityAdapter);
325+
$this->import->expects($this->once())
326+
->method('getForceImport');
324327
$this->_importConfig
325328
->expects($this->any())
326329
->method('getEntities')

app/code/Magento/ImportExport/i18n/en_US.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ Status,Status
8282
"This file does not contain any data.","This file does not contain any data."
8383
"Begin import of ""%1"" with ""%2"" behavior","Begin import of ""%1"" with ""%2"" behavior"
8484
"The import was successful.","The import was successful."
85+
"The import was not successful.","The import was not successful."
8586
"The file you uploaded has no extension.","The file you uploaded has no extension."
8687
"The source file moving process failed.","The source file moving process failed."
8788
"Begin data validation","Begin data validation"

dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ImportWithNotExistImagesTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,6 @@ private function assertImportErrors(): void
222222
RowValidatorInterface::ERROR_MEDIA_URL_NOT_ACCESSIBLE,
223223
$importError->getErrorCode()
224224
);
225-
$errorMsg = (string)__('Imported resource (image) could not be downloaded ' .
226-
'from external resource due to timeout or access permissions');
227-
$this->assertEquals($errorMsg, $importError->getErrorMessage());
228225
}
229226

230227
/**

0 commit comments

Comments
 (0)