public function actionViewCategory() { $page = Yii::$app->getRequest()->getQueryParam('page'); $cateQueryArr = Product::getCategoryArr(); $products = Product::getProductsInCate(['listCategories' => $cateQueryArr, 'limit' => 10, 'page' => $page]); $categories = Category::showCategory(); return $this->render('view-category', ['categories' => $categories, 'products' => $products]); }
public function actionViewCategory() { $page = Yii::$app->getRequest()->getQueryParam('page'); $cateQueryArr = Product::getCategoryArr(); // dd($cateQueryArr); $products = Product::getProductsInCate(['listCategories' => $cateQueryArr, 'limit' => 4, 'page' => $page]); //dd($products); $count = Product::countProduct(); $categories = Category::showCategory(); // dd(count($products)); $pagination = new Pagination(['defaultPageSize' => 5, 'totalCount' => $count]); // dd(count($products)); return $this->render('view-category', ['categories' => $categories, 'products' => $products, 'pagination' => $pagination]); }
public function countProduct() { $listCategories = Product::getCategoryArr(); $count = (new \yii\db\Query())->select('count(*)')->from('product')->where(['category_id' => $listCategories])->scalar(); return $count; }