I do a sample of data from the database. You must select all the products in the current category, as well as in its subcategories. It is easy to do this without a dataprovider if there are connections in the models. But I really want to use dataprovider.
In Yii2, the following code is used to fetch data:
$searchModel = new FooSearch; $dataProvider = $searchModel->search(Yii::$app->request->getQueryParams()); However, the parameters passed by GET need to add default parameters (in my case - category id). If the parameter is one, then it can be done like this :
$searchModel = new FooSearch; $dataProvider = $searchModel->search(ArrayHelper::merge( Yii::$app->request->queryParams, [$searchModel->formName() => ['id_bar' => $id]] )); Or so .
But how to transfer not one parameter, but an array ?