Skip to content

Commit aeab1b7

Browse files
author
Anna Bukatar
committed
ACP2E-863: Duplicate option ids can be included for multi-select attributes when bulk api is called
1 parent cd826aa commit aeab1b7

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

app/code/Magento/Eav/Model/Entity/Attribute/Backend/ArrayBackend.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,25 @@ public function validate($object)
4545
if ($object->hasData($attributeCode)) {
4646
$data = $object->getData($attributeCode);
4747
if (is_array($data)) {
48-
$object->setData($attributeCode, implode(',', array_filter($data)));
48+
$object->setData($attributeCode, $this->filter($data));
49+
} elseif (is_string($data)) {
50+
$object->setData($attributeCode, $this->filter(explode(',', $data)));
4951
} elseif (empty($data)) {
5052
$object->setData($attributeCode, null);
5153
}
5254
}
5355

5456
return parent::validate($object);
5557
}
58+
59+
/**
60+
* Filter attribute values
61+
*
62+
* @param array $data
63+
* @return string
64+
*/
65+
public function filter(array $data): string
66+
{
67+
return implode(',', array_filter(array_unique(($data))));
68+
}
5669
}

0 commit comments

Comments
 (0)