joinWith('lang') ->joinWith('product.lang'); // add conditions that should always apply here $dataProvider = new ActiveDataProvider( [ 'query' => $query, 'sort' => [ 'attributes' => [ 'id', 'title' => [ 'asc' => [ 'variant_lang.title' => SORT_ASC, ], 'desc' => [ 'variant_lang.title' => SORT_DESC, ], ], 'sku', 'product_title' => [ 'asc' => [ 'product_lang.title' => SORT_ASC, ], 'desc' => [ 'product_lang.title' => SORT_DESC, ], ], 'price', 'stock', 'created_at', 'status', 'sort', ], ], ] ); $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( [ 'id' => $this->id, 'variant.product_id' => $this->product_id, 'price' => $this->price, 'price_old' => $this->price_old, 'stock' => $this->stock, 'status' => $this->status, 'sort' => $this->sort, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'sku' => $this->sku, ] ) ->andFilterWhere( [ 'like', 'variant_lang.title', $this->title, ] ) ->andFilterWhere( [ 'like', 'product_lang.title', $this->product_title, ] ); return $dataProvider; } }