Skip to content

Commit 89aa66e

Browse files
committed
Fix importing boolean attributes for categories
Import/Category->indexValueAttributes holds a list of attributes that use the value of a select, rather than the label to update the database. This doesn't match with the validation code, which uses Magento\ImportExport\Model\Import::getAttributeType to
1 parent a72b709 commit 89aa66e

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

Model/Import/Category.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,6 @@ class Category extends \Magento\ImportExport\Model\Import\AbstractEntity
117117
*/
118118
private ?string $entityTable = null;
119119

120-
/**
121-
* Attributes with index (not label) value.
122-
*/
123120
private array $indexValueAttributes = [
124121
'default_sort_by',
125122
CategoryInterface::KEY_AVAILABLE_SORT_BY,
@@ -335,7 +332,13 @@ public function getAttributeOptions(AbstractAttribute $attribute): array
335332

336333
if ($attribute->usesSource()) {
337334
// should attribute has index (option value) instead of a label?
338-
$index = in_array($attribute->getAttributeCode(), $this->indexValueAttributes) ? 'value' : 'label';
335+
$index = 'label';
336+
if (
337+
in_array($attribute->getAttributeCode(), $this->indexValueAttributes) ||
338+
$attribute->getSourceModel() == "Magento\Eav\Model\Entity\Attribute\Source\Boolean"
339+
) {
340+
$index = 'value';
341+
};
339342

340343
// only default (admin) store values used
341344
/** @var Attribute $attribute */

0 commit comments

Comments
 (0)