bundleOptionCollection = $bundleOptionCollection; $this->valueFactory = $valueFactory; $this->metadataPool = $metadataPool; } /** * Fetch and format bundle option items. * * {@inheritDoc} */ public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null) { $linkField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField(); if ($value['type_id'] !== Type::TYPE_CODE || !isset($value[$linkField]) || !isset($value[ProductInterface::SKU]) ) { $result = function () { return null; }; return $this->valueFactory->create($result); } $this->bundleOptionCollection->addParentFilterData( (int)$value[$linkField], (int)$value['entity_id'], $value[ProductInterface::SKU] ); $result = function () use ($value, $linkField) { return $this->bundleOptionCollection->getOptionsByParentId((int)$value[$linkField]); }; return $this->valueFactory->create($result); } }