6 declare(strict_types=1);
30 private $variantCollection;
35 private $optionCollection;
40 private $valueFactory;
45 private $attributeCollection;
50 private $metadataPool;
61 OptionCollection $optionCollection,
66 $this->variantCollection = $variantCollection;
68 $this->valueFactory = $valueFactory;
70 $this->metadataPool = $metadataPool;
80 $linkField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField();
81 if (
$value[
'type_id'] !== Type::TYPE_CODE || !isset(
$value[$linkField])) {
85 return $this->valueFactory->create(
$result);
88 $this->variantCollection->addParentId((
int)
$value[$linkField]);
90 $matchedFields = $this->attributeCollection->getRequestAttributes(
$fields);
91 $this->variantCollection->addEavAttributes($matchedFields);
92 $this->optionCollection->addProductId((
int)
$value[$linkField]);
95 $children = $this->variantCollection->getChildProductsByParentId((
int)
$value[$linkField]);
96 $options = $this->optionCollection->getAttributesByProductId((
int)
$value[$linkField]);
100 $variants[$key] = [
'sku' => $child[
'sku'],
'product' => $child,
'options' =>
$options];
106 return $this->valueFactory->create(
$result);
115 private function getProductFields(ResolveInfo
$info)
118 foreach (
$info->fieldNodes as $node) {
119 if ($node->name->value !==
'product') {
123 foreach ($node->selectionSet->selections as $selectionNode) {
124 $fieldNames[] = $selectionNode->name->value;
__construct(Collection $variantCollection, OptionCollection $optionCollection, ValueFactory $valueFactory, AttributeCollection $attributeCollection, MetadataPool $metadataPool)
foreach( $_productCollection as $_product)() ?>" class $info
resolve(Field $field, $context, ResolveInfo $info, array $value=null, array $args=null)