Answer the question
In order to leave comments, you need to log in
How to display items from root and child categories in listView Yii2?
There are two tables category and item.
A category can have a parent_id i.e. There are parent and child categories.
When a parent is selected, returns only the item with that parent's category_id.
How to add item output from child categories as well?
I tried something all night, but to no avail...
The maximum that happened was to get an array of child categories.
public function getChilds($id)
{
$query = Category::find()->where(['parent_id' => $id])->all();
return $query;
}
Answer the question
In order to leave comments, you need to log in
It seems you need to somehow pass the array to this action in ProductSearch
$query->andFilterWhere([
'id' => $this->id,
'category_id' => $this->category_id,
]);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question