예제 #1
0
 /**
  * Convert option data object value to array representation
  *
  * @param \Magento\Catalog\Service\V1\Product\CustomOptions\Data\Option $option
  * @return array
  */
 public function convert(\Magento\Catalog\Service\V1\Product\CustomOptions\Data\Option $option)
 {
     /** @var Metadata $value */
     $value = current($option->getMetadata());
     $output = [Metadata::PRICE => $value->getPrice(), Metadata::PRICE_TYPE => $value->getPriceType(), Metadata::SKU => $value->getSku()];
     foreach ($value->getCustomAttributes() as $attribute) {
         $output[$attribute->getAttributeCode()] = $attribute->getValue();
     }
     return $output;
 }
예제 #2
0
파일: Select.php 프로젝트: aiesh/magento2
 /**
  * {@inheritdoc}
  */
 public function convert(Option $option)
 {
     $output = [];
     foreach ($option->getMetadata() as $value) {
         $attributes = $value->getCustomAttributes();
         $valueItem = [Metadata::PRICE => $value->getPrice(), Metadata::PRICE_TYPE => $value->getPriceType(), Metadata::SKU => $value->getSku()];
         foreach ($attributes as $attribute) {
             $valueItem[$attribute->getAttributeCode()] = $attribute->getValue();
         }
         $output[] = $valueItem;
     }
     return ['values' => $output];
 }