@@ -299,19 +299,19 @@ protected function _initAttributes()
299
299
}
300
300
}
301
301
$ addedAttributes = [];
302
- foreach ($ absentKeys as $ attributeSetName => $ attributeIds ) {
302
+ foreach ($ absentKeys as $ attributeIds ) {
303
303
$ unknownAttributeIds = array_diff (
304
304
$ attributeIds ,
305
305
array_keys (self ::$ commonAttributesCache ),
306
306
self ::$ invAttributesCache
307
307
);
308
308
if ($ unknownAttributeIds ) {
309
- $ addedAttributes [] = $ this ->attachAttributesByOnlyId ($ attributeSetName , $ unknownAttributeIds );
310
- }
311
- if ($ this ->_forcedAttributesCodes ) {
312
- $ addedAttributes [] = $ this ->attachAttributesByForcedCodes ($ attributeSetName );
309
+ $ addedAttributes [] = $ this ->attachAttributesByOnlyId ($ unknownAttributeIds );
313
310
}
314
311
}
312
+ if ($ this ->_forcedAttributesCodes ) {
313
+ $ addedAttributes [] = $ this ->attachAttributesByForcedCodes ();
314
+ }
315
315
$ addedAttributes = array_merge (...$ addedAttributes );
316
316
$ attributesToLoadFromTable = [];
317
317
foreach ($ addedAttributes as $ addedAttribute ) {
@@ -361,8 +361,9 @@ protected function _initAttributes()
361
361
* @param string $attributeSetName
362
362
* @param array $attributeIds
363
363
* @return void
364
- * @deprecated use attachAttributesOnlyById and attachAttributesByForcedCodes
365
- * @see attachAttributesOnlyById() and attachAttributesByForcedCodes()
364
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
365
+ * @deprecated use attachAttributesByOnlyId and attachAttributesByForcedCodes
366
+ * @see attachAttributesByOnlyId() and attachAttributesByForcedCodes()
366
367
*/
367
368
protected function attachAttributesById ($ attributeSetName , $ attributeIds )
368
369
{
@@ -373,25 +374,24 @@ protected function attachAttributesById($attributeSetName, $attributeIds)
373
374
['in ' => $ this ->_forcedAttributesCodes ]
374
375
]
375
376
) as $ attribute ) {
376
- $ this ->attachAttribute ($ attributeSetName , $ attribute );
377
+ $ this ->attachAttribute ($ attribute );
377
378
}
378
379
}
379
380
380
381
/**
381
382
* Attach Attributes By Id
382
383
*
383
- * @param string $attributeSetName
384
384
* @param array $attributeIds
385
385
* @return array
386
386
*/
387
- private function attachAttributesByOnlyId (string $ attributeSetName , array $ attributeIds ) : array
387
+ private function attachAttributesByOnlyId (array $ attributeIds ) : array
388
388
{
389
389
$ addedAttributes = [];
390
390
foreach ($ this ->_prodAttrColFac ->create ()->addFieldToFilter (
391
391
['main_table.attribute_id ' , 'main_table.attribute_code ' ],
392
392
[['in ' => $ attributeIds ]]
393
393
) as $ attribute ) {
394
- $ cachedAttribute = $ this ->attachAttribute ($ attributeSetName , $ attribute );
394
+ $ cachedAttribute = $ this ->attachAttribute ($ attribute );
395
395
if (null !== $ cachedAttribute ) {
396
396
$ addedAttributes [] = $ cachedAttribute ;
397
397
}
@@ -402,17 +402,16 @@ private function attachAttributesByOnlyId(string $attributeSetName, array $attri
402
402
/**
403
403
* Attach Attributes By _forcedAttributesCodes
404
404
*
405
- * @param string $attributeSetName
406
405
* @return array
407
406
*/
408
- private function attachAttributesByForcedCodes (string $ attributeSetName ) : array
407
+ private function attachAttributesByForcedCodes () : array
409
408
{
410
409
$ addedAttributes = [];
411
410
foreach ($ this ->_prodAttrColFac ->create ()->addFieldToFilter (
412
411
['main_table.attribute_code ' ],
413
412
[['in ' => $ this ->_forcedAttributesCodes ]]
414
413
) as $ attribute ) {
415
- $ cachedAttribute = $ this ->attachAttribute ($ attributeSetName , $ attribute );
414
+ $ cachedAttribute = $ this ->attachAttribute ($ attribute );
416
415
if (null !== $ cachedAttribute ) {
417
416
$ addedAttributes [] = $ cachedAttribute ;
418
417
}
@@ -423,11 +422,10 @@ private function attachAttributesByForcedCodes(string $attributeSetName) : array
423
422
/**
424
423
* Attach Attribute to self::$commonAttributesCache or self::$invAttributesCache
425
424
*
426
- * @param string $attributeSetName
427
425
* @param ProductAttributeInterface $attribute
428
426
* @return array|null
429
427
*/
430
- private function attachAttribute (string $ attributeSetName , ProductAttributeInterface $ attribute )
428
+ private function attachAttribute (ProductAttributeInterface $ attribute )
431
429
{
432
430
$ cachedAttribute = null ;
433
431
$ attributeCode = $ attribute ->getAttributeCode ();
0 commit comments