/** * @return string * @throws ServerErrorHttpException */ public function actionIndex() { $searchModel = new Product(); $params = Yii::$app->request->get(); /** @var ActiveDataProvider $dataProvider */ $dataProvider = $searchModel->search($params); if (null !== ($catId = Yii::$app->request->get('parent_id'))) { $dataProvider->query->leftJoin(Object::getForClass(Product::className())->categories_table_name . ' cp', 'cp.object_model_id=product.id')->andWhere('product.parent_id=0 AND cp.category_id=:cur', [':cur' => $catId]); } return $this->render('index', ['dataProvider' => $dataProvider, 'searchModel' => $searchModel]); }