public function actionDetail() { $data = $this->getCommonDate(); $modelBest = Goods::getBest(3); $iP = Yii::$app->session->id; $quantityInCart = Cart::getQountAllByIp($iP); $id = Yii::$app->request->get('item'); $modelReview = Review::getReviewsByGoodId($id); $modelGoodsCategories = GoodsCategory::find()->all(); $modelBrends = Brend::find()->all(); if (!$id) { $this->redirect('/shop/index'); } $model = Goods::getItemById($id); $modelPhotos = GoodsPhotos::getItemsByGoodId($id); $_modelReview = new Review(); return $this->render('detail', ['modelPhotos' => $modelPhotos, 'data' => $data, 'model' => $model, 'modelGoodsCategories' => $modelGoodsCategories, 'modelReview' => $modelReview, '_modelReview' => $_modelReview, 'modelBest' => $modelBest, 'modelBrends' => $modelBrends]); }
public function actionGetGoodsByPriceRange() { $cur = Yii::$app->request->post('valute'); $data = Yii::$app->request->post('data'); $dataFrom = $data['0']; $dataTo = $data['1']; //vd($dataFrom.'|' . $dataTo); // $modelGoods = Goods::getGoodsByPriceRange($dataFrom ,$dataTo,$cur); $query = Goods::find()->where(['>', 'price', $dataFrom])->AndWhere(['<', 'price', $dataTo])->AndWhere(['status' => Goods::STATUS_ACTIVE]); $countQuery = clone $query; $pages = new Pagination(['totalCount' => $countQuery->count(), 'defaultPageSize' => 2]); $modelsGoods = $query->offset($pages->offset)->limit(3)->all(); Yii::$app->response->format = Response::FORMAT_JSON; $iP = Yii::$app->session->id; $quantityInCart = Cart::getQountAllByIp($iP); $data = $this->getCommonDate(); $modelBest = Goods::getBest(3); return $this->renderAjax('products-ajax', ['modelsGoods' => $modelsGoods, 'pages' => $pages, 'modelBest' => $modelBest ? $modelBest : false]); }