@@ -267,6 +267,10 @@ protected function _getProductAttributes($attrSetData)
267
267
/**
268
268
* Initialize attributes parameters for all attributes' sets.
269
269
*
270
+ * @SuppressWarnings(PHPMD.CyclomaticComplexity)
271
+ * @SuppressWarnings(PHPMD.NPathComplexity)
272
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
273
+ *
270
274
* @return $this
271
275
*/
272
276
protected function _initAttributes ()
@@ -311,16 +315,16 @@ protected function _initAttributes()
311
315
$ addedAttributes = array_merge (...$ addedAttributes );
312
316
$ attributesToLoadFromTable = [];
313
317
foreach ($ addedAttributes as $ addedAttribute ) {
314
- if (isset ($ addedAttribute ['options_use_table ' ])) {
318
+ if (isset ($ addedAttribute ['options_use_table ' ])) {
315
319
$ attributesToLoadFromTable [] = $ addedAttribute ['id ' ];
316
- unset(self ::$ commonAttributesCache [$ addedAttribute ['id ' ]]['options_use_table ' ]);
320
+ unset(self ::$ commonAttributesCache [$ addedAttribute ['id ' ]]['options_use_table ' ]);
317
321
}
318
322
}
319
323
if (!empty ($ attributesToLoadFromTable )) {
320
324
$ collection = $ this ->attributeOptionCollectionFactory ->create ();
321
325
$ collection ->setAttributeFilter (['in ' => $ attributesToLoadFromTable ]);
322
326
$ collection ->setStoreFilter (\Magento \Store \Model \Store::DEFAULT_STORE_ID );
323
- foreach ($ collection as $ option ) {
327
+ foreach ($ collection as $ option ) {
324
328
$ attributeId = $ option ->getAttributeId ();
325
329
$ value = strtolower ($ option ->getValue ());
326
330
self ::$ commonAttributesCache [$ attributeId ]['options ' ][$ value ] = $ option ->getOptionId ();
@@ -369,7 +373,7 @@ protected function attachAttributesById($attributeSetName, $attributeIds)
369
373
['in ' => $ this ->_forcedAttributesCodes ]
370
374
]
371
375
) as $ attribute ) {
372
- $ this ->attachAttribute ($ attributeSetName , $ attribute );
376
+ $ this ->attachAttribute ($ attributeSetName , $ attribute );
373
377
}
374
378
}
375
379
@@ -417,13 +421,14 @@ private function attachAttributesByForcedCodes(string $attributeSetName) : array
417
421
}
418
422
419
423
/**
420
- * Attach Attributes By Id
424
+ * Attach Attribute to self::$commonAttributesCache or self::$invAttributesCache
421
425
*
422
426
* @param string $attributeSetName
423
427
* @param ProductAttributeInterface $attribute
424
428
* @return array|null
425
429
*/
426
- private function attachAttribute (string $ attributeSetName , ProductAttributeInterface $ attribute ) {
430
+ private function attachAttribute (string $ attributeSetName , ProductAttributeInterface $ attribute )
431
+ {
427
432
$ cachedAttribute = null ;
428
433
$ attributeCode = $ attribute ->getAttributeCode ();
429
434
$ attributeId = $ attribute ->getId ();
0 commit comments