diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/AbstractBackend.php b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/AbstractBackend.php index fab2ed182f30e..206bff163f201 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/AbstractBackend.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/AbstractBackend.php @@ -231,13 +231,14 @@ public function validate($object) $attribute = $this->getAttribute(); $attrCode = $attribute->getAttributeCode(); $value = $object->getData($attrCode); + $label = $attribute->getFrontend()->getLabel(); if ($attribute->getIsVisible() && $attribute->getIsRequired() && $attribute->isValueEmpty($value) && $attribute->isValueEmpty($attribute->getDefaultValue()) ) { - throw new LocalizedException(__('The value of attribute "%1" must be set', $attrCode)); + throw new LocalizedException(__('The value of attribute "%1" must be set', $label)); } if ($attribute->getIsUnique() @@ -248,8 +249,7 @@ public function validate($object) } if ($attribute->getIsUnique()) { - if (!$attribute->getEntity()->checkAttributeUniqueValue($attribute, $object)) { - $label = $attribute->getFrontend()->getLabel(); + if (!$attribute->getEntity()->checkAttributeUniqueValue($attribute, $object)) { throw new LocalizedException(__('The value of attribute "%1" must be unique', $label)); } }