From dd40f2b799381aa8475815774344eb4771920bef Mon Sep 17 00:00:00 2001 From: Hewerson Freitas Date: Wed, 8 Nov 2017 16:33:12 -0300 Subject: [PATCH] Update AbstractBackend.php Hello guys, when the validation message is returned, the attribute code is displayed. That prevents a better translation for other languages, has been adjusted to return the label instead of the attribute code. Adjustments on lines 234, 241, 254. --- .../Eav/Model/Entity/Attribute/Backend/AbstractBackend.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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)); } }