コード例 #1
0
ファイル: FrontendController.php プロジェクト: khuebt/gem
 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]);
 }
コード例 #2
0
ファイル: FrontendController.php プロジェクト: khuebt/yii
 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]);
 }
コード例 #3
0
ファイル: Product.php プロジェクト: khuebt/yii
 public function countProduct()
 {
     $listCategories = Product::getCategoryArr();
     $count = (new \yii\db\Query())->select('count(*)')->from('product')->where(['category_id' => $listCategories])->scalar();
     return $count;
 }