Skip to content

Commit 8169bca

Browse files
committed
ACP2E-3660: REST endpoint Product Import Json not validate the mandatory fields
1 parent 99b5896 commit 8169bca

File tree

4 files changed

+8
-17
lines changed

4 files changed

+8
-17
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ public function isRowValid(array $rowData, $rowNum, $isNewProduct = true)
583583
// For the default scope - if this is a new product or
584584
// for an old product, if the imported doc has the column present for the attrCode
585585
if (Product::SCOPE_DEFAULT == $rowScope &&
586-
($isNewProduct || !in_array($attrCode,self::NON_REQUIRED_ATTRIBUTES_EXISTING_PRODUCTS)) &&
586+
($isNewProduct || !in_array($attrCode, self::NON_REQUIRED_ATTRIBUTES_EXISTING_PRODUCTS)) &&
587587
array_key_exists($attrCode, $rowData)
588588
) {
589589
$this->_entityModel->addRowError(

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

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -382,9 +382,8 @@ public function getInvalidAttribute()
382382
* Is valid attributes
383383
*
384384
* @return array
385-
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
386385
*/
387-
protected function isValidAttributes(): array
386+
protected function isValidAttributes()
388387
{
389388
$this->_clearMessages();
390389
$this->setInvalidAttribute(null);
@@ -441,7 +440,7 @@ public function isValid($value)
441440
}
442441
}
443442

444-
return !in_array(false, array_values($validatedAttributes['attributes']));
443+
return count($this->_messages) == 0;
445444
}
446445

447446
/**
@@ -458,16 +457,6 @@ public function getRowScope(array $rowData)
458457
return Product::SCOPE_STORE;
459458
}
460459

461-
private function getValidatorFields(): array
462-
{
463-
$validatorFields = [];
464-
/** @var Product\Validator\AbstractImportValidator $validator */
465-
foreach($this->validators as $validator) {
466-
$validatorFields[] = $validator->getFieldName();
467-
}
468-
return $validatorFields;
469-
}
470-
471460
/**
472461
* Validate category names
473462
*

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ abstract class AbstractImportValidator extends AbstractValidator implements RowV
2121
protected $context;
2222

2323
/**
24-
* @param \Magento\CatalogImportExport\Model\Import\Product $context
25-
* @return $this
24+
* @inheritDoc
2625
*/
2726
public function init($context)
2827
{
@@ -31,6 +30,8 @@ public function init($context)
3130
}
3231

3332
/**
33+
* Get validating field name
34+
*
3435
* @return string|null
3536
*/
3637
public function getFieldName(): ?string

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,8 @@ public function testIsRowValidError()
331331
{
332332
$rowData = [
333333
'_attribute_set' => 'attribute_set_name',
334-
'sku' => 'sku'
334+
'sku' => 'sku',
335+
'attr_code' => 'test'
335336
];
336337
$rowNum = 1;
337338
$this->entityModel->method('getRowScope')

0 commit comments

Comments
 (0)