public static function SaveValue($products_propertiesXML) { foreach ($products_propertiesXML as $products_property) { $product_id = (int) $products_property->product_id; $name = (string) $products_property->property_name; $value = (string) $products_property->value_name; // $value = ProductsProperties::findOne($name); // // if ( is_null($value)) { // создаем запись $model = new ProductsProperties(); $model->product_id = $product_id; $model->property_name = $name; $model->value_name = $value; $model->save(false); // } // else { // // // обновляем запись // $value->product_id = $product_id; // $value->property_name = $name; // $value->value_name = $value; // $value->save(false); // // } } }
public function getProperties() { $query = ProductsProperties::find()->where(['product_id' => $this->product_id]); $dataProvider = new ActiveDataProvider(['query' => $query]); return $dataProvider; }