Skip to content

Commit f9374c8

Browse files
seperate reserved key check & use self instead of static
1 parent 9c38339 commit f9374c8

File tree

1 file changed

+10
-8
lines changed
  • app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute

1 file changed

+10
-8
lines changed

app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Validate.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,16 @@ public function execute()
128128
$attributeCode
129129
);
130130

131-
if ($attribute->getId() && !$attributeId || in_array($attributeCode, static::RESERVED_CODES)) {
132-
if (in_array($attributeCode, static::RESERVED_CODES)) {
133-
$message = __('Code (%1) is a reserved key and cannot be used as attribute code.', $attributeCode);
134-
} else {
135-
$message = strlen($this->getRequest()->getParam('attribute_code'))
136-
? __('An attribute with this code already exists.')
137-
: __('An attribute with the same code (%1) already exists.', $attributeCode);
138-
}
131+
if (in_array($attributeCode, self::RESERVED_CODES)) {
132+
$message = __('Code (%1) is a reserved key and cannot be used as attribute code.', $attributeCode);
133+
$this->setMessageToResponse($response, [$message]);
134+
$response->setError(true);
135+
}
136+
137+
if ($attribute->getId() && !$attributeId) {
138+
$message = strlen($this->getRequest()->getParam('attribute_code'))
139+
? __('An attribute with this code already exists.')
140+
: __('An attribute with the same code (%1) already exists.', $attributeCode);
139141
$this->setMessageToResponse($response, [$message]);
140142

141143
$response->setError(true);

0 commit comments

Comments
 (0)