Помогли решить на воркзиле
public function search($params)
{
$query = Product::find()
->from(['p' => Product::tableName()])
->with(['designer', 'category']);
// add conditions that should always apply here
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
// grid filtering conditions
$query->andFilterWhere([
'p.id' => $this->id,
//'p.category_id' => $this->category_id,
'p.designer_id' => $this->designer_id,
'p.price' => $this->price,
'p.new' => $this->new,
'p.hit' => $this->hit,
'p.sale' => $this->sale,
'p.created_at' => $this->created_at,
'p.updated_at' => $this->updated_at,
// 'p2.childrenProducts' => $this->category_id
]);
if (!empty($this->category_id)) {
$ids = Category::find()->andWhere(['parent_id'=>[$this->category_id]])->alias('p2')->column();
$ids[] = $this->category_id;
$query->andWhere(['p.category_id' => array_unique($ids)]);
}
$query->andFilterWhere(['like', 'title', $this->title])
->andFilterWhere(['like', 'art', $this->art])
->andFilterWhere(['like', 'meta_key', $this->meta_key])
->andFilterWhere(['like', 'meta_description', $this->meta_description])
->andFilterWhere(['like', 'description', $this->description])
->andFilterWhere(['like', 'image_alt', $this->image_alt]);
return $dataProvider;
}