@@ -332,34 +332,25 @@ private function identifySuperAttributeError($superAttrCode, $rowNum)
332332 {
333333 // This attribute code is not a super attribute. Need to give a clearer message why?
334334 $ reasonFound = false ;
335-
336335 $ codeExists = false ;
337- $ codeNotGlobal = false ;
338- $ codeNotTypeSelect = false ;
336+
339337 // Does this attribute code exist?
340338 $ sourceAttribute = $ this ->doesSuperAttributeExist ($ superAttrCode );
341- if (count ($ sourceAttribute )) {
339+ if (! is_null ($ sourceAttribute )) {
342340 $ codeExists = true ;
343341 // Does attribute have the correct settings?
344- if (is_array ($ sourceAttribute) ) {
345- if ( isset ( $ sourceAttribute [ ' is_global ' ]) && $ sourceAttribute [ ' is_global ' ] !== ' 1 ' ) {
346- $ codeNotGlobal = true ;
347- } elseif (isset ($ sourceAttribute ['type ' ]) && $ sourceAttribute ['type ' ] !== 'select ' ) {
348- $ codeNotTypeSelect = true ;
349- }
342+ if (isset ($ sourceAttribute[ ' is_global ' ]) && $ sourceAttribute [ ' is_global ' ] !== ' 1 ' ) {
343+ $ this -> _entityModel -> addRowError ( self :: ERROR_ATTRIBUTE_CODE_NOT_GLOBAL_SCOPE , $ rowNum , $ superAttrCode );
344+ $ reasonFound = true ;
345+ } elseif (isset ($ sourceAttribute ['type ' ]) && $ sourceAttribute ['type ' ] !== 'select ' ) {
346+ $ this -> _entityModel -> addRowError ( self :: ERROR_ATTRIBUTE_CODE_NOT_TYPE_SELECT , $ rowNum , $ superAttrCode ) ;
347+ $ reasonFound = true ;
350348 }
351349 }
352350
353- // Identify (if any) the correct fault:
354351 if ($ codeExists === false ) {
355352 $ this ->_entityModel ->addRowError (self ::ERROR_ATTRIBUTE_CODE_DOES_NOT_EXIST , $ rowNum , $ superAttrCode );
356353 $ reasonFound = true ;
357- } elseif ($ codeNotGlobal === true ) {
358- $ this ->_entityModel ->addRowError (self ::ERROR_ATTRIBUTE_CODE_NOT_GLOBAL_SCOPE , $ rowNum , $ superAttrCode );
359- $ reasonFound = true ;
360- } elseif ($ codeNotTypeSelect === true ) {
361- $ this ->_entityModel ->addRowError (self ::ERROR_ATTRIBUTE_CODE_NOT_TYPE_SELECT , $ rowNum , $ superAttrCode );
362- $ reasonFound = true ;
363354 }
364355
365356 return $ reasonFound ;
@@ -373,20 +364,22 @@ private function identifySuperAttributeError($superAttrCode, $rowNum)
373364 */
374365 private function doesSuperAttributeExist ($ superAttrCode )
375366 {
376- $ returnFilterArray = [];
377- if (is_array (self ::$ commonAttributesCache ))
378- {
367+ $ returnAttributeArray = null ;
368+ if (is_array (self ::$ commonAttributesCache )) {
379369 $ filteredAttribute = array_filter (
380370 self ::$ commonAttributesCache ,
381371 function ($ element ) use ($ superAttrCode ) {
382372 return $ element ['code ' ] == $ superAttrCode ;
383373 }
384374 );
385375
386- // Return the first element of the filtered array.
387- $ returnFilterArray = array_shift ($ filteredAttribute );
376+ // Return the first element of the filtered array (if found).
377+ if (count ($ filteredAttribute ))
378+ {
379+ $ returnAttributeArray = array_shift ($ filteredAttribute );
380+ }
388381 }
389- return $ returnFilterArray ;
382+ return $ returnAttributeArray ;
390383 }
391384
392385 /**
0 commit comments