Skip to content

Commit 3e9d8e3

Browse files
committed
MAGETWO-70036: Change EAV attribute value validation
1 parent 6dd8451 commit 3e9d8e3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,16 @@ public function beforeSave($object)
3838
*/
3939
public function validate($object)
4040
{
41-
$attributeCode = $this->getAttribute()->getAttributeCode();
41+
$attribute = $this->getAttribute();
42+
$attributeCode = $attribute->getAttributeCode();
4243
$data = $object->getData($attributeCode);
44+
$assigned = $object->hasData($attributeCode);
4345
if (is_array($data)) {
4446
$object->setData($attributeCode, implode(',', array_filter($data)));
45-
} elseif (empty($data)) {
47+
} elseif (empty($data) && $assigned) {
4648
$object->setData($attributeCode, null);
4749
}
50+
4851
return parent::validate($object);
4952
}
5053
}

0 commit comments

Comments
 (0)