14 private $customAttributeFactory;
24 private $variationMatrix;
37 $this->customAttributeFactory = $customAttributeFactory;
38 $this->variationMatrix = $variationMatrix;
50 $variations = $this->variationMatrix->getVariations(
$attributes);
52 foreach ($variations as $variation) {
55 $item = $this->productFactory->create();
59 foreach ($variation as $attributeId => $valueInfo) {
60 $suffix .=
'-' . $valueInfo[
'value'];
61 $customAttribute = $this->customAttributeFactory->create()
62 ->setAttributeCode(
$attributes[$attributeId][
'attribute_code'])
63 ->setValue($valueInfo[
'value']);
64 $customAttributes = array_merge(
65 $item->getCustomAttributes(),
67 $attributes[$attributeId][
'attribute_code'] => $customAttribute
70 $item->setData(
'custom_attributes', $customAttributes);
75 $item->setVisibility(\
Magento\Catalog\Model\Product\Visibility::VISIBILITY_NOT_VISIBLE);
__construct(\Magento\Catalog\Model\ProductFactory $productFactory, \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory, \Magento\ConfigurableProduct\Model\Product\Type\VariationMatrix $variationMatrix)