@@ -332,34 +332,25 @@ private function identifySuperAttributeError($superAttrCode, $rowNum)
332
332
{
333
333
// This attribute code is not a super attribute. Need to give a clearer message why?
334
334
$ reasonFound = false ;
335
-
336
335
$ codeExists = false ;
337
- $ codeNotGlobal = false ;
338
- $ codeNotTypeSelect = false ;
336
+
339
337
// Does this attribute code exist?
340
338
$ sourceAttribute = $ this ->doesSuperAttributeExist ($ superAttrCode );
341
- if (count ($ sourceAttribute )) {
339
+ if (! is_null ($ sourceAttribute )) {
342
340
$ codeExists = true ;
343
341
// 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 ;
350
348
}
351
349
}
352
350
353
- // Identify (if any) the correct fault:
354
351
if ($ codeExists === false ) {
355
352
$ this ->_entityModel ->addRowError (self ::ERROR_ATTRIBUTE_CODE_DOES_NOT_EXIST , $ rowNum , $ superAttrCode );
356
353
$ 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 ;
363
354
}
364
355
365
356
return $ reasonFound ;
@@ -373,20 +364,22 @@ private function identifySuperAttributeError($superAttrCode, $rowNum)
373
364
*/
374
365
private function doesSuperAttributeExist ($ superAttrCode )
375
366
{
376
- $ returnFilterArray = [];
377
- if (is_array (self ::$ commonAttributesCache ))
378
- {
367
+ $ returnAttributeArray = null ;
368
+ if (is_array (self ::$ commonAttributesCache )) {
379
369
$ filteredAttribute = array_filter (
380
370
self ::$ commonAttributesCache ,
381
371
function ($ element ) use ($ superAttrCode ) {
382
372
return $ element ['code ' ] == $ superAttrCode ;
383
373
}
384
374
);
385
375
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
+ }
388
381
}
389
- return $ returnFilterArray ;
382
+ return $ returnAttributeArray ;
390
383
}
391
384
392
385
/**
0 commit comments