@@ -298,52 +298,13 @@ protected function _isParticularAttributesValid(array $rowData, $rowNum)
298
298
{
299
299
if (!empty ($ rowData ['_super_attribute_code ' ])) {
300
300
$ superAttrCode = $ rowData ['_super_attribute_code ' ];
301
-
302
301
if (!$ this ->_isAttributeSuper ($ superAttrCode )) {
303
- // This attribute code is not a super attribute. Need to give a clearer message why?
304
- $ codeExists = false ;
305
- $ codeNotGlobal = false ;
306
- $ codeNotTypeSelect = false ;
307
- // Does this attribute code exist? Does is have the correct settings?
308
- $ commonAttributes = self ::$ commonAttributesCache ;
309
- foreach ($ commonAttributes as $ attributeRow ) {
310
-
311
- if ($ attributeRow ['code ' ] == $ superAttrCode )
312
- {
313
- $ codeExists = true ;
314
-
315
- if ($ attributeRow ['is_global ' ] !== '1 ' )
316
- {
317
- $ codeNotGlobal = true ;
318
- }
319
- elseif ($ attributeRow ['type ' ] !== 'select ' )
320
- {
321
- $ codeNotTypeSelect = true ;
322
- }
323
-
324
- break ;
325
- }
326
- }
327
-
328
- if ($ codeExists == false )
329
- {
330
- $ this ->_entityModel ->addRowError (self ::ERROR_ATTRIBUTE_CODE_DOES_NOT_EXIST , $ rowNum , $ superAttrCode );
331
- return false ;
332
- }
333
- elseif ($ codeNotGlobal == true )
302
+ // Identify reason why attribute is not super:
303
+ if (!$ this ->_identifySuperAttributeError ($ superAttrCode , $ rowNum ))
334
304
{
335
- $ this ->_entityModel ->addRowError (self ::ERROR_ATTRIBUTE_CODE_NOT_GLOBAL_SCOPE , $ rowNum , $ superAttrCode );
336
- return false ;
305
+ $ this ->_entityModel ->addRowError (self ::ERROR_ATTRIBUTE_CODE_IS_NOT_SUPER , $ rowNum , $ superAttrCode );
337
306
}
338
- elseif ($ codeNotTypeSelect == true )
339
- {
340
- $ this ->_entityModel ->addRowError (self ::ERROR_ATTRIBUTE_CODE_NOT_TYPE_SELECT , $ rowNum , $ superAttrCode );
341
- return false ;
342
- }
343
-
344
- $ this ->_entityModel ->addRowError (self ::ERROR_ATTRIBUTE_CODE_IS_NOT_SUPER , $ rowNum , $ superAttrCode );
345
307
return false ;
346
-
347
308
} elseif (isset ($ rowData ['_super_attribute_option ' ]) && strlen ($ rowData ['_super_attribute_option ' ])) {
348
309
$ optionKey = strtolower ($ rowData ['_super_attribute_option ' ]);
349
310
if (!isset ($ this ->_superAttributes [$ superAttrCode ]['options ' ][$ optionKey ])) {
@@ -355,6 +316,61 @@ protected function _isParticularAttributesValid(array $rowData, $rowNum)
355
316
return true ;
356
317
}
357
318
319
+ /**
320
+ * Identify exactly why a super attribute code is not super.
321
+ *
322
+ * @param string $superAttrCode
323
+ * @param int $rowNum
324
+ * @return bool
325
+ */
326
+ protected function _identifySuperAttributeError ($ superAttrCode , $ rowNum )
327
+ {
328
+ // This attribute code is not a super attribute. Need to give a clearer message why?
329
+ $ reasonFound = false ;
330
+
331
+ $ codeExists = false ;
332
+ $ codeNotGlobal = false ;
333
+ $ codeNotTypeSelect = false ;
334
+ // Does this attribute code exist? Does is have the correct settings?
335
+ $ commonAttributes = self ::$ commonAttributesCache ;
336
+ foreach ($ commonAttributes as $ attributeRow ) {
337
+
338
+ if ($ attributeRow ['code ' ] == $ superAttrCode )
339
+ {
340
+ $ codeExists = true ;
341
+
342
+ if ($ attributeRow ['is_global ' ] !== '1 ' )
343
+ {
344
+ $ codeNotGlobal = true ;
345
+ }
346
+ elseif ($ attributeRow ['type ' ] !== 'select ' )
347
+ {
348
+ $ codeNotTypeSelect = true ;
349
+ }
350
+
351
+ break ;
352
+ }
353
+ }
354
+
355
+ if ($ codeExists == false )
356
+ {
357
+ $ this ->_entityModel ->addRowError (self ::ERROR_ATTRIBUTE_CODE_DOES_NOT_EXIST , $ rowNum , $ superAttrCode );
358
+ $ reasonFound = true ;
359
+ }
360
+ elseif ($ codeNotGlobal == true )
361
+ {
362
+ $ this ->_entityModel ->addRowError (self ::ERROR_ATTRIBUTE_CODE_NOT_GLOBAL_SCOPE , $ rowNum , $ superAttrCode );
363
+ $ reasonFound = true ;
364
+ }
365
+ elseif ($ codeNotTypeSelect == true )
366
+ {
367
+ $ this ->_entityModel ->addRowError (self ::ERROR_ATTRIBUTE_CODE_NOT_TYPE_SELECT , $ rowNum , $ superAttrCode );
368
+ $ reasonFound = true ;
369
+ }
370
+
371
+ return $ reasonFound ;
372
+ }
373
+
358
374
/**
359
375
* Array of SKU to array of super attribute values for all products.
360
376
*
0 commit comments