Skip to content

Commit 77ed839

Browse files
authored
ENGCOM-4034: Fixed issue when only first custom option was validated #20769
2 parents 28fa795 + c38bcc3 commit 77ed839

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,10 @@ protected function _initMessageTemplates()
431431
);
432432
$this->_productEntity->addMessageTemplate(
433433
self::ERROR_INVALID_TYPE,
434-
__('Value for \'type\' sub attribute in \'custom_options\' attribute contains incorrect value, acceptable values are: \'dropdown\', \'checkbox\'')
434+
__(
435+
'Value for \'type\' sub attribute in \'custom_options\' attribute contains incorrect value, acceptable values are: %1',
436+
'\''.implode('\', \'', array_keys($this->_specificTypes)).'\''
437+
)
435438
);
436439
$this->_productEntity->addMessageTemplate(self::ERROR_EMPTY_TITLE, __('Please enter a value for title.'));
437440
$this->_productEntity->addMessageTemplate(
@@ -629,7 +632,7 @@ public function validateAmbiguousData()
629632
$this->_addRowsErrors(self::ERROR_AMBIGUOUS_NEW_NAMES, $errorRows);
630633
return false;
631634
}
632-
if ($this->getBehavior() == \Magento\ImportExport\Model\Import::BEHAVIOR_APPEND) {
635+
if ($this->getBehavior() == Import::BEHAVIOR_APPEND) {
633636
$errorRows = $this->_findOldOptionsWithTheSameTitles();
634637
if ($errorRows) {
635638
$this->_addRowsErrors(self::ERROR_AMBIGUOUS_OLD_NAMES, $errorRows);
@@ -967,11 +970,10 @@ public function validateRow(array $rowData, $rowNumber)
967970
return false;
968971
}
969972
}
970-
return true;
971973
}
972974
}
973975

974-
return false;
976+
return true;
975977
}
976978

977979
/**
@@ -1381,7 +1383,7 @@ private function setLastOptionTitle(array &$titles) : void
13811383
*/
13821384
private function removeExistingOptions(array $products, array $optionsToRemove): void
13831385
{
1384-
if ($this->getBehavior() != \Magento\ImportExport\Model\Import::BEHAVIOR_APPEND) {
1386+
if ($this->getBehavior() != Import::BEHAVIOR_APPEND) {
13851387
$this->_deleteEntities(array_keys($products));
13861388
} elseif (!empty($optionsToRemove)) {
13871389
// Remove options for products with empty "custom_options" row
@@ -2108,7 +2110,7 @@ private function savePreparedCustomOptions(
21082110
array $types
21092111
): void {
21102112
if ($this->_isReadyForSaving($options, $titles, $types['values'])) {
2111-
if ($this->getBehavior() == \Magento\ImportExport\Model\Import::BEHAVIOR_APPEND) {
2113+
if ($this->getBehavior() == Import::BEHAVIOR_APPEND) {
21122114
$this->_compareOptionsWithExisting($options, $titles, $prices, $types['values']);
21132115
$this->restoreOriginalOptionTypeIds($types['values'], $types['prices'], $types['titles']);
21142116
}

app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Type/OptionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ public function testValidateRowNoCustomOption()
702702
{
703703
$rowData = include __DIR__ . '/_files/row_data_no_custom_option.php';
704704
$this->_bypassModelMethodGetMultiRowFormat($rowData);
705-
$this->assertFalse($this->modelMock->validateRow($rowData, 0));
705+
$this->assertTrue($this->modelMock->validateRow($rowData, 0));
706706
}
707707

708708
/**

0 commit comments

Comments
 (0)