File tree Expand file tree Collapse file tree 1 file changed +3
-24
lines changed
app/code/Magento/CatalogGraphQl/Model/Resolver/Product Expand file tree Collapse file tree 1 file changed +3
-24
lines changed Original file line number Diff line number Diff line change @@ -108,10 +108,9 @@ function (AttributeInterface $customAttribute) {
108108 }
109109 $ attributeValue = $ productData [$ attributeCode ] ?? "" ;
110110 if (is_array ($ attributeValue )) {
111- $ attributeValue = implode (
112- ', ' ,
113- $ this ->getFlatArrayIfArrayIsMultiDimentional ($ attributeValue )
114- );
111+ $ attributeValue = (count ($ attributeValue ) != count ($ attributeValue , COUNT_RECURSIVE ))
112+ ? json_encode ($ attributeValue )
113+ : implode (', ' , $ attributeValue );
115114 }
116115 $ customAttributes [] = [
117116 'attribute_code ' => $ attributeCode ,
@@ -133,24 +132,4 @@ function (array $customAttribute) {
133132 'errors ' => $ productCustomAttributes ['errors ' ]
134133 ];
135134 }
136-
137- /**
138- * Returns flat array if the array passed is multidimentional
139- *
140- * @param array $array
141- * @return array
142- */
143- private function getFlatArrayIfArrayIsMultiDimentional (array $ array ): array
144- {
145- // Check if it's a multi-dimensional array
146- $ isMultiDimensional = (count ($ array ) != count ($ array , COUNT_RECURSIVE ));
147- if ($ isMultiDimensional ) {
148- $ flatArray = [];
149- array_walk_recursive ($ array , function ($ item ) use (&$ flatArray ) {
150- $ flatArray [] = $ item ;
151- });
152- $ array = $ flatArray ;
153- }
154- return $ array ;
155- }
156135}
You can’t perform that action at this time.
0 commit comments