@@ -28,6 +28,13 @@ abstract class AbstractType
28
28
*/
29
29
public static $ commonAttributesCache = [];
30
30
31
+ /**
32
+ * Maintain a list of invisible attributes
33
+ *
34
+ * @var array
35
+ */
36
+ public static $ invisibleAttributesCache = [];
37
+
31
38
/**
32
39
* Attribute Code to Id cache
33
40
*
@@ -278,7 +285,10 @@ protected function _initAttributes()
278
285
}
279
286
}
280
287
foreach ($ absentKeys as $ attributeSetName => $ attributeIds ) {
281
- $ this ->attachAttributesById ($ attributeSetName , $ attributeIds );
288
+ $ unknownAttributeIds = array_diff ($ attributeIds , array_keys (self ::$ commonAttributesCache ), self ::$ invisibleAttributesCache );
289
+ if ($ unknownAttributeIds ) {
290
+ $ this ->attachAttributesById ($ attributeSetName , $ attributeIds );
291
+ }
282
292
}
283
293
foreach ($ entityAttributes as $ attributeRow ) {
284
294
if (isset (self ::$ commonAttributesCache [$ attributeRow ['attribute_id ' ]])) {
@@ -310,30 +320,35 @@ protected function attachAttributesById($attributeSetName, $attributeIds)
310
320
$ attributeId = $ attribute ->getId ();
311
321
312
322
if ($ attribute ->getIsVisible () || in_array ($ attributeCode , $ this ->_forcedAttributesCodes )) {
313
- self ::$ commonAttributesCache [$ attributeId ] = [
314
- 'id ' => $ attributeId ,
315
- 'code ' => $ attributeCode ,
316
- 'is_global ' => $ attribute ->getIsGlobal (),
317
- 'is_required ' => $ attribute ->getIsRequired (),
318
- 'is_unique ' => $ attribute ->getIsUnique (),
319
- 'frontend_label ' => $ attribute ->getFrontendLabel (),
320
- 'is_static ' => $ attribute ->isStatic (),
321
- 'apply_to ' => $ attribute ->getApplyTo (),
322
- 'type ' => \Magento \ImportExport \Model \Import::getAttributeType ($ attribute ),
323
- 'default_value ' => strlen (
324
- $ attribute ->getDefaultValue ()
325
- ) ? $ attribute ->getDefaultValue () : null ,
326
- 'options ' => $ this ->_entityModel ->getAttributeOptions (
327
- $ attribute ,
328
- $ this ->_indexValueAttributes
329
- ),
330
- ];
323
+ if (!isset (self ::$ commonAttributesCache [$ attributeId ])) {
324
+ self ::$ commonAttributesCache [$ attributeId ] = [
325
+ 'id ' => $ attributeId ,
326
+ 'code ' => $ attributeCode ,
327
+ 'is_global ' => $ attribute ->getIsGlobal (),
328
+ 'is_required ' => $ attribute ->getIsRequired (),
329
+ 'is_unique ' => $ attribute ->getIsUnique (),
330
+ 'frontend_label ' => $ attribute ->getFrontendLabel (),
331
+ 'is_static ' => $ attribute ->isStatic (),
332
+ 'apply_to ' => $ attribute ->getApplyTo (),
333
+ 'type ' => \Magento \ImportExport \Model \Import::getAttributeType ($ attribute ),
334
+ 'default_value ' => strlen (
335
+ $ attribute ->getDefaultValue ()
336
+ ) ? $ attribute ->getDefaultValue () : null ,
337
+ 'options ' => $ this ->_entityModel ->getAttributeOptions (
338
+ $ attribute ,
339
+ $ this ->_indexValueAttributes
340
+ ),
341
+ ];
342
+ }
343
+
331
344
self ::$ attributeCodeToId [$ attributeCode ] = $ attributeId ;
332
345
$ this ->_addAttributeParams (
333
346
$ attributeSetName ,
334
347
self ::$ commonAttributesCache [$ attributeId ],
335
348
$ attribute
336
349
);
350
+ } else {
351
+ self ::$ invisibleAttributesCache [] = $ attributeId ;
337
352
}
338
353
}
339
354
}
0 commit comments