Skip to content

Commit

Permalink
Fix importing boolean attributes for categories
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rbrown committed Oct 21, 2022
1 parent a72b709 commit 89aa66e
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Model/Import/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,6 @@ class Category extends \Magento\ImportExport\Model\Import\AbstractEntity
*/
private ?string $entityTable = null;

/**
* Attributes with index (not label) value.
*/
private array $indexValueAttributes = [
'default_sort_by',
CategoryInterface::KEY_AVAILABLE_SORT_BY,
Expand Down Expand Up @@ -335,7 +332,13 @@ public function getAttributeOptions(AbstractAttribute $attribute): array

if ($attribute->usesSource()) {
// should attribute has index (option value) instead of a label?
$index = in_array($attribute->getAttributeCode(), $this->indexValueAttributes) ? 'value' : 'label';
$index = 'label';
if (
in_array($attribute->getAttributeCode(), $this->indexValueAttributes) ||
$attribute->getSourceModel() == "Magento\Eav\Model\Entity\Attribute\Source\Boolean"
) {
$index = 'value';
};

// only default (admin) store values used
/** @var Attribute $attribute */
Expand Down

0 comments on commit 89aa66e

Please sign in to comment.