Skip to content

Commit 21d34c3

Browse files
committed
LYNX-100: Return UNDEFINED for frontend_input if not set for attribute
1 parent de85101 commit 21d34c3

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

app/code/Magento/EavGraphQl/Model/Output/GetAttributeData.php

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
<?php
2+
23
/**
34
* Copyright © Magento, Inc. All rights reserved.
45
* See COPYING.txt for license details.
56
*/
7+
68
declare(strict_types=1);
79

810
namespace Magento\EavGraphQl\Model\Output;
@@ -69,10 +71,7 @@ public function execute(
6971
'AttributeEntityTypeEnum',
7072
$entityType
7173
),
72-
'frontend_input' => $this->enumLookup->getEnumValueFromField(
73-
'AttributeFrontendInputEnum',
74-
$attribute->getFrontendInput() ?? ""
75-
),
74+
'frontend_input' => $this->getFrontendInput($attribute),
7675
'is_required' => $attribute->getIsRequired(),
7776
'default_value' => $attribute->getDefaultValue(),
7877
'is_unique' => $attribute->getIsUnique(),
@@ -81,6 +80,23 @@ public function execute(
8180
];
8281
}
8382

83+
/**
84+
* Returns default frontend input for attribute if not set
85+
*
86+
* @param AttributeInterface $attribute
87+
* @return string
88+
*/
89+
private function getFrontendInput(AttributeInterface $attribute): string
90+
{
91+
if ($attribute->getFrontendInput() == null) {
92+
return "UNDEFINED";
93+
}
94+
return $this->enumLookup->getEnumValueFromField(
95+
'AttributeFrontendInputEnum',
96+
$attribute->getFrontendInput() ?? "undefined"
97+
);
98+
}
99+
84100
/**
85101
* Retrieve formatted attribute options
86102
*

app/code/Magento/EavGraphQl/etc/schema.graphqls

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ enum AttributeFrontendInputEnum @doc(description: "EAV attribute frontend input
110110
TEXT
111111
TEXTAREA
112112
WEIGHT
113+
UNDEFINED
113114
}
114115

115116
type AttributesFormOutput @doc(description: "Metadata of EAV attributes associated to form") {

0 commit comments

Comments
 (0)