Skip to content

Commit dd40f2b

Browse files
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.
1 parent 838cff7 commit dd40f2b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,14 @@ public function validate($object)
231231
$attribute = $this->getAttribute();
232232
$attrCode = $attribute->getAttributeCode();
233233
$value = $object->getData($attrCode);
234+
$label = $attribute->getFrontend()->getLabel();
234235

235236
if ($attribute->getIsVisible()
236237
&& $attribute->getIsRequired()
237238
&& $attribute->isValueEmpty($value)
238239
&& $attribute->isValueEmpty($attribute->getDefaultValue())
239240
) {
240-
throw new LocalizedException(__('The value of attribute "%1" must be set', $attrCode));
241+
throw new LocalizedException(__('The value of attribute "%1" must be set', $label));
241242
}
242243

243244
if ($attribute->getIsUnique()
@@ -248,8 +249,7 @@ public function validate($object)
248249
}
249250

250251
if ($attribute->getIsUnique()) {
251-
if (!$attribute->getEntity()->checkAttributeUniqueValue($attribute, $object)) {
252-
$label = $attribute->getFrontend()->getLabel();
252+
if (!$attribute->getEntity()->checkAttributeUniqueValue($attribute, $object)) {
253253
throw new LocalizedException(__('The value of attribute "%1" must be unique', $label));
254254
}
255255
}

0 commit comments

Comments
 (0)