controllers/ProductController.php
/**
     * Lists all Product models.
     * @return mixed
     */
Lists all Product models.
@return mixed
Lists all Product models . @return mixed
public function actionIndex($id)
    {
        $searchModel = new CategorySearch();
        $searchModel->search(Yii::$app->request->queryParams);
        $data = $searchModel -> outTree($id,0);
        $categories_id[] = $id;
        foreach($data as $category){
            $categories_id[] = $category -> id;
        }
        $products = Product::find()
            ->andWhere(['IN', 'category_id', $categories_id])
            ->all();
        return $this->render('index', [
            'data' => $products,
            'category_id' => $id
        ]);
    }
public function actionIndex ( $ id ) { $ searchModel = new CategorySearch ( ) ; $ searchModel -> search ( Yii :: $ app -> request -> queryParams ) ; $ data = $ searchModel -> outTree ( $ id , 0 ) ; $ categories_id [ ] = $ id ; foreach ( $ data as $ category ) { $ categories_id [ ] = $ category -> id ; } $ products = Product :: find ( ) -> andWhere ( [ 'IN' , 'category_id' , $ categories_id ] ) -> all ( ) ; return $ this -> render ( 'index' , [ 'data' => $ products , 'category_id' => $ id ] ) ; }
Lists all Product models.
Lists all Product models .
//        select all products where category_id in [id and data's->id]