modules/admin/controllers/ProductController.php
/**
     * Lists all Products models.
     * @return mixed
     */
Lists all Products models.
@return mixed
Lists all Products models . @return mixed
public function actionIndex()
    {
        $searchModel = new ProductSearch();
        $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
        $categories = ArrayHelper::map(ProductCategory::find()->where(['parent_category_id' => null])->all(), 'id', function ($data) {
            return $data['name'];
        });
        $subCategories = ArrayHelper::map(ProductCategory::find()->where(['IS NOT', 'parent_category_id', null])->all(), 'id', function ($data) {
            return $data['name'];
        });
        $productType = [Product::PRODUCT_TYPE_NEW => 'New', Product::PRODUCT_TYPE_USED => 'Used'];
        $statuses = ArrayHelper::map(ProductStatus::find()->all(), 'id', 'status');
        return $this->render('index', [
            'searchModel' => $searchModel,
            'dataProvider' => $dataProvider,
            'categories' => $categories,
            'subCategories' => $subCategories,
            'productType' => $productType,
            'arrStatus' => $statuses
        ]);
    }
public function actionIndex ( ) { $ searchModel = new ProductSearch ( ) ; $ dataProvider = $ searchModel -> search ( Yii :: $ app -> request -> queryParams ) ; $ categories = ArrayHelper :: map ( ProductCategory :: find ( ) -> where ( [ 'parent_category_id' => null ] ) -> all ( ) , 'id' , function ( $ data ) { return $ data [ 'name' ] ; } ) ; $ subCategories = ArrayHelper :: map ( ProductCategory :: find ( ) -> where ( [ 'IS NOT' , 'parent_category_id' , null ] ) -> all ( ) , 'id' , function ( $ data ) { return $ data [ 'name' ] ; } ) ; $ productType = [ Product :: PRODUCT_TYPE_NEW => 'New' , Product :: PRODUCT_TYPE_USED => 'Used' ] ; $ statuses = ArrayHelper :: map ( ProductStatus :: find ( ) -> all ( ) , 'id' , 'status' ) ; return $ this -> render ( 'index' , [ 'searchModel' => $ searchModel , 'dataProvider' => $ dataProvider , 'categories' => $ categories , 'subCategories' => $ subCategories , 'productType' => $ productType , 'arrStatus' => $ statuses ] ) ; }
Lists all Products models.
Lists all Products models .