Skip to content

Commit 2d5c946

Browse files
committed
Merge branch 'ACP2E-2647' of https://github.com/magento-l3/magento2ce into PR-12-19-2023
2 parents c154689 + bbd5612 commit 2d5c946

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ public function validate($object)
6464
*/
6565
private function prepare(array $data): string
6666
{
67-
return implode(',', array_filter(array_unique($data), 'is_numeric'));
67+
return implode(
68+
',',
69+
array_filter(
70+
array_unique($data),
71+
fn($value) => is_numeric($value) || !empty($value)
72+
)
73+
);
6874
}
6975
}

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,26 @@ public static function validateDataProvider(): array
8787
['sku' => 'test1', 'attr' => '0,1,2,3,4'],
8888
true,
8989
'0,1,2,3,4'
90+
],
91+
'keeps non numeric values from string' => [
92+
['sku' => 'test1', 'attr' => 'foo,bar'],
93+
true,
94+
'foo,bar'
95+
],
96+
'keeps non numeric values from array' => [
97+
['sku' => 'test1', 'attr' => ['foo','bar']],
98+
true,
99+
'foo,bar'
100+
],
101+
'filters empty values from string' => [
102+
['sku' => 'test1', 'attr' => 'foo,bar,,123'],
103+
true,
104+
'foo,bar,123'
105+
],
106+
'filters empty values from array' => [
107+
['sku' => 'test1', 'attr' => ['foo','bar','',null,123]],
108+
true,
109+
'foo,bar,123'
90110
]
91111
];
92112
}

0 commit comments

Comments
 (0)