@@ -336,18 +336,11 @@ private function identifySuperAttributeError($superAttrCode, $rowNum)
336
336
$ codeExists = false ;
337
337
$ codeNotGlobal = false ;
338
338
$ 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 )) {
348
342
$ codeExists = true ;
349
- // Examine the first element of the filtered array
350
- $ sourceAttribute = array_shift ($ filterAttribute );
343
+ // Does attribute have the correct settings?
351
344
if (is_array ($ sourceAttribute )) {
352
345
if (isset ($ sourceAttribute ['is_global ' ]) && $ sourceAttribute ['is_global ' ] !== '1 ' ) {
353
346
$ codeNotGlobal = true ;
@@ -357,20 +350,45 @@ function ($element) use($superAttrCode) {
357
350
}
358
351
}
359
352
353
+ // Identify (if any) the correct fault:
360
354
if ($ codeExists === false ) {
361
355
$ this ->_entityModel ->addRowError (self ::ERROR_ATTRIBUTE_CODE_DOES_NOT_EXIST , $ rowNum , $ superAttrCode );
362
356
$ reasonFound = true ;
363
- } elseif ($ codeNotGlobal == true ) {
357
+ } elseif ($ codeNotGlobal === true ) {
364
358
$ this ->_entityModel ->addRowError (self ::ERROR_ATTRIBUTE_CODE_NOT_GLOBAL_SCOPE , $ rowNum , $ superAttrCode );
365
359
$ reasonFound = true ;
366
- } elseif ($ codeNotTypeSelect == true ) {
360
+ } elseif ($ codeNotTypeSelect === true ) {
367
361
$ this ->_entityModel ->addRowError (self ::ERROR_ATTRIBUTE_CODE_NOT_TYPE_SELECT , $ rowNum , $ superAttrCode );
368
362
$ reasonFound = true ;
369
363
}
370
364
371
365
return $ reasonFound ;
372
366
}
373
367
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
+
374
392
/**
375
393
* Array of SKU to array of super attribute values for all products.
376
394
*
0 commit comments