There is a task to gradually move from MySQL to mongodb now, so as not to knock down the work of the site while translating only the product, while duplicating it in two databases. The question is: there are two models of Goods and Addfields in the form of saving the Good model; there are some properties of the AddFields model in Mongo;
"_id":"5a02d9afb2d45753294debc6", "title":"Костюм женский 'Маргарита'", "slug":"goods-Kostum-zenskij-Margarita", "discription":"<p>Цвет: темно синий, светло бежевый, голубой, ментол, сиреневый, бордовый. Оттенки могут отличаться.</p>" "product_id": 2576, "addField":[ "quote":"Цвет: темно синий, светло бежевый, голубой, ментол, сиреневый, бордовый. Оттенки могут", "size1":"48-50;52-54", "shop": "0", "composition":"дайвинг", "country":"Украина", "delivery":"3-5 дней", "site":"bole-ro", "winter""0", "spring":"0", "summer":"0", "fall":"0" ] addField this document is formed from both the properties of the Good and Addfields . And if with the Goods I get more or less, and it’s understandable and succeeded. Then there are problems with Addfields like this: I created a Mongo entry (the Addfield structure Addfield such an 'id' , 'id_goods' , 'key_field' , 'value' )
$product=Products::find()->where(['product_id'=>$this->id_goods])->one(); $key=$this->key_feild; $product['addFeild'][$key]=$this->value; $product->save(); parent::afterSave($insert, $changedAttributes); but I get the following error
Indirect modification of overloaded element of common \ models \ mongo \ Products has no effect
swears at this line
$product['addFeild'][$key]=$this->value; What am I doing wrong and how is it right?
id_godswith one “o”, and according to the logic of things there should be two. - Dmytryk