/**
  * {@inheritdoc}
  */
 public function setProduct(ProductInterface $product = null)
 {
     parent::setEntity($product);
 }
Esempio n. 2
0
 /**
  * @param $config
  * @return AttributeValueInterface
  */
 public static function getAttributeValueInstance($config = [])
 {
     return AttributeValue::getInstance($config);
 }
 /**
  * Returns rendered form fields for requested attributes.
  *
  * @return string
  */
 public function actionFields()
 {
     if (($attributes = Yii::$app->request->post('attributes')) && ($form = Yii::$app->request->post('form'))) {
         $attributes = Attribute::findAll(['id' => $attributes]);
         /** @var EavTrait $modelClass */
         $modelClass = Yii::$app->request->post('modelClass');
         $values = [];
         foreach ($attributes as $attribute) {
             $value = $modelClass ? $modelClass::getAttributeValueInstance() : AttributeValue::getInstance();
             $value->setEAttribute($attribute);
             $values[$attribute->getName()] = $value;
         }
         if (Yii::$app->request->isAjax) {
             return $this->renderAjax('_fields', ['attributes' => $values, 'form' => $form]);
         }
     }
 }