Exemplo n.º 1
0
 function actionProducts()
 {
     $categoria_id = Yii::$app->request->get('categoria');
     $brand_id = Yii::$app->request->get('brand');
     if ($categoria_id) {
         $query = Goods::find()->where(['status' => 1, 'category_id' => $categoria_id]);
     } elseif ($brand_id) {
         $query = Goods::find()->where(['status' => 1, 'brend_id' => $brand_id]);
     } else {
         $query = Goods::find()->where(['status' => 1]);
     }
     $countQuery = clone $query;
     $pages = new Pagination(['totalCount' => $countQuery->count(), 'defaultPageSize' => 2]);
     $modelsGoods = $query->offset($pages->offset)->limit(3)->all();
     $data = $this->getCommonDate();
     $iP = Yii::$app->session->id;
     $quantityInCart = Cart::getQountAllByIp($iP);
     $model = Cart::getAllByIp($iP);
     $modelBrends = Brend::find()->all();
     $modelNewGoods = Goods::getNewest(15);
     $modelGoodsCategories = GoodsCategory::find()->all();
     return $this->render('products', ['modelsGoods' => $modelsGoods, 'pages' => $pages, 'data' => $data, 'modelNewGoods' => $modelNewGoods, 'modelGoodsCategories' => $modelGoodsCategories, 'model' => $model, 'modelBrends' => $modelBrends, 'quantityInCart' => $quantityInCart]);
 }