Exemple #1
0
 /**
  * @param Option $option
  * @param Attribute $configurableAttribute
  * @return Attribute
  */
 public function getModelFromData(Option $option, Attribute $configurableAttribute)
 {
     /** @var \Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute $returnConfigurableAttribute */
     $returnConfigurableAttribute = $this->attributeFactory->create();
     $returnConfigurableAttribute->setData($configurableAttribute->getData());
     $returnConfigurableAttribute->addData($option->__toArray());
     $returnConfigurableAttribute->setId($configurableAttribute->getId());
     $returnConfigurableAttribute->setAttributeId($configurableAttribute->getAttributeId());
     $returnConfigurableAttribute->setValues($configurableAttribute->getPrices());
     $values = $option->getValues();
     if (!is_null($values)) {
         $prices = [];
         foreach ($values as $value) {
             $prices[] = $this->valueConverter->convertArrayFromData($value);
         }
         $returnConfigurableAttribute->setValues($prices);
     }
     return $returnConfigurableAttribute;
 }