@@ -336,18 +336,11 @@ private function identifySuperAttributeError($superAttrCode, $rowNum)
336336 $ codeExists = false ;
337337 $ codeNotGlobal = false ;
338338 $ codeNotTypeSelect = false ;
339- // Does this attribute code exist? Does it have the correct settings?
340- $ filterAttribute = array_filter (
341- self ::$ commonAttributesCache ,
342- function ($ element ) use ($ superAttrCode ) {
343- return $ element ['code ' ] == $ superAttrCode ;
344- }
345- );
346-
347- if (is_array ($ filterAttribute ) && count ($ filterAttribute )) {
339+ // Does this attribute code exist?
340+ $ sourceAttribute = $ this ->doesSuperAttributeExist ($ superAttrCode );
341+ if (count ($ sourceAttribute )) {
348342 $ codeExists = true ;
349- // Examine the first element of the filtered array
350- $ sourceAttribute = array_shift ($ filterAttribute );
343+ // Does attribute have the correct settings?
351344 if (is_array ($ sourceAttribute )) {
352345 if (isset ($ sourceAttribute ['is_global ' ]) && $ sourceAttribute ['is_global ' ] !== '1 ' ) {
353346 $ codeNotGlobal = true ;
@@ -357,20 +350,45 @@ function ($element) use($superAttrCode) {
357350 }
358351 }
359352
353+ // Identify (if any) the correct fault:
360354 if ($ codeExists === false ) {
361355 $ this ->_entityModel ->addRowError (self ::ERROR_ATTRIBUTE_CODE_DOES_NOT_EXIST , $ rowNum , $ superAttrCode );
362356 $ reasonFound = true ;
363- } elseif ($ codeNotGlobal == true ) {
357+ } elseif ($ codeNotGlobal === true ) {
364358 $ this ->_entityModel ->addRowError (self ::ERROR_ATTRIBUTE_CODE_NOT_GLOBAL_SCOPE , $ rowNum , $ superAttrCode );
365359 $ reasonFound = true ;
366- } elseif ($ codeNotTypeSelect == true ) {
360+ } elseif ($ codeNotTypeSelect === true ) {
367361 $ this ->_entityModel ->addRowError (self ::ERROR_ATTRIBUTE_CODE_NOT_TYPE_SELECT , $ rowNum , $ superAttrCode );
368362 $ reasonFound = true ;
369363 }
370364
371365 return $ reasonFound ;
372366 }
373367
368+ /**
369+ * Does the super attribute exist in the current attribute set?
370+ *
371+ * @param string $superAttrCode
372+ * @return array
373+ */
374+ private function doesSuperAttributeExist ($ superAttrCode )
375+ {
376+ $ returnFilterArray = [];
377+ if (is_array (self ::$ commonAttributesCache ))
378+ {
379+ $ filteredAttribute = array_filter (
380+ self ::$ commonAttributesCache ,
381+ function ($ element ) use ($ superAttrCode ) {
382+ return $ element ['code ' ] == $ superAttrCode ;
383+ }
384+ );
385+
386+ // Return the first element of the filtered array.
387+ $ returnFilterArray = array_shift ($ filteredAttribute );
388+ }
389+ return $ returnFilterArray ;
390+ }
391+
374392 /**
375393 * Array of SKU to array of super attribute values for all products.
376394 *
0 commit comments