Skip to content

Commit 4348f7e

Browse files
committed
Ignore empty value for certain category attributes firegento#144
1 parent e4cb43f commit 4348f7e

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

Model/Import/Category.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,17 @@ class Category extends \Magento\ImportExport\Model\Import\AbstractEntity
172172
self::COL_CATEGORY
173173
];
174174

175+
/**
176+
* List of fields that can used config values in case when value does not defined directly
177+
*
178+
* @var array
179+
*/
180+
protected $useConfigFields = [
181+
'available_sort_by',
182+
'default_sort_by',
183+
'filter_price_range'
184+
];
185+
175186
private ?int $errorsLimit = null;
176187
private array $invalidRows = [];
177188

@@ -816,7 +827,8 @@ public function validateRow(array $rowData, $rowNum)
816827
foreach ($this->attributes as $attrCode => $attrParams) {
817828
if (isset($rowData[$attrCode]) && strlen($rowData[$attrCode])) {
818829
$this->isAttributeValid($attrCode, $attrParams, $rowData, $rowNum);
819-
} elseif ($attrParams['is_required'] && !isset($this->categoriesWithRoots[$root][$category])) {
830+
} elseif ($attrParams['is_required'] && !isset($this->categoriesWithRoots[$root][$category])
831+
&& !in_array($attrCode, $this->useConfigFields)) {
820832
$this->addRowError(self::ERROR_VALUE_IS_REQUIRED, $rowNum, $attrCode);
821833
}
822834
}

0 commit comments

Comments
 (0)