/** * {@inheritdoc} */ public function read(\Magento\Catalog\Model\Product\Option $option) { $fields = [Metadata::PRICE => $option->getPrice(), Metadata::PRICE_TYPE => $option->getPriceType(), Metadata::SKU => $option->getSku()]; $fields = array_merge($fields, $this->getCustomAttributes($option)); $value = $this->valueBuilder->populateWithArray($fields)->create(); return [$value]; }
/** * {@inheritdoc} */ public function read(\Magento\Catalog\Model\Product\Option $option) { $output = []; foreach ($option->getValues() as $value) { $output[] = $this->metadataBuilder->populateWithArray([Metadata::PRICE => $value->getPrice(), Metadata::PRICE_TYPE => $value->getPriceType(), Metadata::SKU => $value->getSku(), Metadata::TITLE => $value->getTitle(), Metadata::SORT_ORDER => $value->getSortOrder(), Metadata::OPTION_TYPE_ID => $value->getId()])->create(); } return $output; }