Skip to content

Commit c324758

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 aeab1b7 commit c324758

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ public function validate($object)
4545
if ($object->hasData($attributeCode)) {
4646
$data = $object->getData($attributeCode);
4747
if (is_array($data)) {
48-
$object->setData($attributeCode, $this->filter($data));
48+
$object->setData($attributeCode, $this->prepare($data));
4949
} elseif (is_string($data)) {
50-
$object->setData($attributeCode, $this->filter(explode(',', $data)));
50+
$object->setData($attributeCode, $this->prepare(explode(',', $data)));
5151
} elseif (empty($data)) {
5252
$object->setData($attributeCode, null);
5353
}
@@ -57,13 +57,13 @@ public function validate($object)
5757
}
5858

5959
/**
60-
* Filter attribute values
60+
* Prepare attribute values
6161
*
6262
* @param array $data
6363
* @return string
6464
*/
65-
public function filter(array $data): string
65+
private function prepare(array $data): string
6666
{
67-
return implode(',', array_filter(array_unique(($data))));
67+
return implode(',', array_filter(array_unique($data), 'is_numeric'));
6868
}
6969
}

app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Backend/ArrayBackendTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,16 @@ public static function validateDataProvider(): array
7878
false,
7979
null,
8080
],
81+
[
82+
['sku' => 'test1', 'attr' => '13,13'],
83+
true,
84+
'13'
85+
],
86+
[
87+
['sku' => 'test1', 'attr' => '0,1,2,3,4'],
88+
true,
89+
'0,1,2,3,4'
90+
]
8191
];
8292
}
8393

0 commit comments

Comments
 (0)