@@ -231,6 +231,7 @@ protected function prepareVariations()
231231 {
232232 $ productMatrix = $ attributes = [];
233233 $ variants = $ this ->getVariantAttributeComposition ();
234+ $ productIds = [];
234235 foreach ($ this ->getAssociatedProducts () as $ product ) {
235236 $ childProductOptions = [];
236237 $ productIds [] = $ product ->getId ();
@@ -246,12 +247,8 @@ protected function prepareVariations()
246247 'attribute_code ' => $ attribute ->getAttributeCode (),
247248 'attribute_label ' => $ attribute ->getStoreLabel (0 ),
248249 '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 ' ]
255252 ];
256253 $ attributes [$ attribute ->getAttributeId ()]['chosen ' ][] = $ variationOption ;
257254 }
@@ -408,8 +405,7 @@ private function buildAttributeDetails(AbstractAttribute $attribute): array
408405 'label ' => $ attribute ->getStoreLabel (),
409406 'id ' => $ attribute ->getAttributeId (),
410407 'position ' => $ configurableAttributes [$ attribute ->getAttributeId ()]['position ' ],
411- 'chosen ' => [],
412- '__disableTmpl ' => true
408+ 'chosen ' => []
413409 ];
414410
415411 foreach ($ attribute ->getOptions () as $ option ) {
@@ -419,8 +415,7 @@ private function buildAttributeDetails(AbstractAttribute $attribute): array
419415 'attribute_label ' => $ attribute ->getStoreLabel (0 ),
420416 'id ' => $ option ['value ' ],
421417 'label ' => $ option ['label ' ],
422- 'value ' => $ option ['value ' ],
423- '__disableTmpl ' => true ,
418+ 'value ' => $ option ['value ' ]
424419 ];
425420 }
426421 }
@@ -436,29 +431,23 @@ private function buildAttributeDetails(AbstractAttribute $attribute): array
436431 */
437432 private function buildChildProductOption (array $ attributeDetails ): array
438433 {
439- $ label = $ this ->extractAttributeValueLabel (
440- $ attributeDetails ['attribute ' ],
441- $ attributeDetails ['value_id ' ]
442- );
443-
444434 return [
445435 'attribute_code ' => $ attributeDetails ['attribute ' ]->getAttributeCode (),
446436 'attribute_label ' => $ attributeDetails ['attribute ' ]->getStoreLabel (0 ),
447437 '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 ' ]
451440 ];
452441 }
453442
454443 /**
455444 * Get label for a specific value of an attribute.
456445 *
457- * @param $attribute
446+ * @param AbstractAttribute $attribute
458447 * @param int $valueId
459448 * @return string
460449 */
461- private function extractAttributeValueLabel ($ attribute , int $ valueId ): string
450+ private function extractAttributeValueLabel (AbstractAttribute $ attribute , int $ valueId ): string
462451 {
463452 foreach ($ attribute ->getOptions () as $ attributeOption ) {
464453 if ($ attributeOption ->getValue () == $ valueId ) {
@@ -469,7 +458,6 @@ private function extractAttributeValueLabel($attribute, int $valueId): string
469458 return '' ;
470459 }
471460
472-
473461 /**
474462 * Create child product details
475463 *
@@ -483,10 +471,9 @@ private function buildChildProductDetails(Product $product, array $childProductO
483471 $ currency = $ this ->localeCurrency ->getCurrency ($ this ->locator ->getBaseCurrencyCode ());
484472 return [
485473 '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> ' ,
490477 'sku ' => $ product ->getSku (),
491478 'name ' => $ product ->getName (),
492479 'qty ' => $ this ->getProductStockQty ($ product ),
@@ -518,6 +505,10 @@ private function getVariantAttributeComposition(): array
518505 $ variants [$ product ->getId ()][$ attribute ->getAttributeCode ()] =
519506 [
520507 'value_id ' => $ product ->getData ($ attribute ->getAttributeCode ()),
508+ 'label ' => $ this ->extractAttributeValueLabel (
509+ $ attribute ,
510+ $ product ->getData ($ attribute ->getAttributeCode ())
511+ ),
521512 'attribute ' => $ attribute
522513 ];
523514 }
0 commit comments