Answer the question
In order to leave comments, you need to log in
How to implement multi-attribute search in Yii2 EAV model?
Search by one attribute turns out everything works, but for several attributes I can’t catch up with how to do a search ((
my code
$productsQuery = Product::find()->joinWith('values')
->andWhere(['product.category_id' => $category->id])
->andWhere(['like', 'value.value', '%'.$size])
->andWhere(['value.attribute_id'=>$sizeAttr['id']])->all();
Answer the question
In order to leave comments, you need to log in
The general scheme is to create a search model class and, depending on the GET parameters received, connect the appropriate filters to the $query object in it.
In your question instead of andWhere use andFilterWhere
https://github.com/yiisoft/yii2/blob/master/docs/g...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question