@@ -231,6 +231,7 @@ protected function prepareVariations()
231
231
{
232
232
$ productMatrix = $ attributes = [];
233
233
$ variants = $ this ->getVariantAttributeComposition ();
234
+ $ productIds = [];
234
235
foreach ($ this ->getAssociatedProducts () as $ product ) {
235
236
$ childProductOptions = [];
236
237
$ productIds [] = $ product ->getId ();
@@ -246,12 +247,8 @@ protected function prepareVariations()
246
247
'attribute_code ' => $ attribute ->getAttributeCode (),
247
248
'attribute_label ' => $ attribute ->getStoreLabel (0 ),
248
249
'id ' => $ attributeComposition ['value_id ' ],
249
- 'label ' => $ this ->extractAttributeValueLabel (
250
- $ attribute ,
251
- $ attributeComposition ['value_id ' ]
252
- ),
253
- 'value ' => $ attributeComposition ['value_id ' ],
254
- '__disableTmpl ' => true ,
250
+ 'label ' => $ attributeComposition ['label ' ],
251
+ 'value ' => $ attributeComposition ['value_id ' ]
255
252
];
256
253
$ attributes [$ attribute ->getAttributeId ()]['chosen ' ][] = $ variationOption ;
257
254
}
@@ -408,8 +405,7 @@ private function buildAttributeDetails(AbstractAttribute $attribute): array
408
405
'label ' => $ attribute ->getStoreLabel (),
409
406
'id ' => $ attribute ->getAttributeId (),
410
407
'position ' => $ configurableAttributes [$ attribute ->getAttributeId ()]['position ' ],
411
- 'chosen ' => [],
412
- '__disableTmpl ' => true
408
+ 'chosen ' => []
413
409
];
414
410
415
411
foreach ($ attribute ->getOptions () as $ option ) {
@@ -419,8 +415,7 @@ private function buildAttributeDetails(AbstractAttribute $attribute): array
419
415
'attribute_label ' => $ attribute ->getStoreLabel (0 ),
420
416
'id ' => $ option ['value ' ],
421
417
'label ' => $ option ['label ' ],
422
- 'value ' => $ option ['value ' ],
423
- '__disableTmpl ' => true ,
418
+ 'value ' => $ option ['value ' ]
424
419
];
425
420
}
426
421
}
@@ -436,29 +431,23 @@ private function buildAttributeDetails(AbstractAttribute $attribute): array
436
431
*/
437
432
private function buildChildProductOption (array $ attributeDetails ): array
438
433
{
439
- $ label = $ this ->extractAttributeValueLabel (
440
- $ attributeDetails ['attribute ' ],
441
- $ attributeDetails ['value_id ' ]
442
- );
443
-
444
434
return [
445
435
'attribute_code ' => $ attributeDetails ['attribute ' ]->getAttributeCode (),
446
436
'attribute_label ' => $ attributeDetails ['attribute ' ]->getStoreLabel (0 ),
447
437
'id ' => $ attributeDetails ['value_id ' ],
448
- 'label ' => $ label ,
449
- 'value ' => $ attributeDetails ['value_id ' ],
450
- '__disableTmpl ' => true ,
438
+ 'label ' => $ attributeDetails ['value_id ' ],
439
+ 'value ' => $ attributeDetails ['value_id ' ]
451
440
];
452
441
}
453
442
454
443
/**
455
444
* Get label for a specific value of an attribute.
456
445
*
457
- * @param $attribute
446
+ * @param AbstractAttribute $attribute
458
447
* @param int $valueId
459
448
* @return string
460
449
*/
461
- private function extractAttributeValueLabel ($ attribute , int $ valueId ): string
450
+ private function extractAttributeValueLabel (AbstractAttribute $ attribute , int $ valueId ): string
462
451
{
463
452
foreach ($ attribute ->getOptions () as $ attributeOption ) {
464
453
if ($ attributeOption ->getValue () == $ valueId ) {
@@ -469,7 +458,6 @@ private function extractAttributeValueLabel($attribute, int $valueId): string
469
458
return '' ;
470
459
}
471
460
472
-
473
461
/**
474
462
* Create child product details
475
463
*
@@ -483,10 +471,9 @@ private function buildChildProductDetails(Product $product, array $childProductO
483
471
$ currency = $ this ->localeCurrency ->getCurrency ($ this ->locator ->getBaseCurrencyCode ());
484
472
return [
485
473
'id ' => $ product ->getId (),
486
- 'product_link ' => '<a href=" ' . $ this ->urlBuilder ->getUrl (
487
- 'catalog/product/edit ' ,
488
- ['id ' => $ product ->getId ()]
489
- ) . '" target="_blank"> ' . $ this ->escaper ->escapeHtml ($ product ->getName ()) . '</a> ' ,
474
+ 'product_link ' => '<a href=" ' .
475
+ $ this ->urlBuilder ->getUrl ('catalog/product/edit ' , ['id ' => $ product ->getId ()])
476
+ . '" target="_blank"> ' . $ this ->escaper ->escapeHtml ($ product ->getName ()) . '</a> ' ,
490
477
'sku ' => $ product ->getSku (),
491
478
'name ' => $ product ->getName (),
492
479
'qty ' => $ this ->getProductStockQty ($ product ),
@@ -518,6 +505,10 @@ private function getVariantAttributeComposition(): array
518
505
$ variants [$ product ->getId ()][$ attribute ->getAttributeCode ()] =
519
506
[
520
507
'value_id ' => $ product ->getData ($ attribute ->getAttributeCode ()),
508
+ 'label ' => $ this ->extractAttributeValueLabel (
509
+ $ attribute ,
510
+ $ product ->getData ($ attribute ->getAttributeCode ())
511
+ ),
521
512
'attribute ' => $ attribute
522
513
];
523
514
}
0 commit comments