Ejemplo n.º 1
0
 public static function reviews($id, $flag = "")
 {
     $reviews = News::items('', "product_id =" . $id);
     $count = 0;
     foreach ($reviews as $review) {
         $count += $review->no_of_review;
     }
     if ($count > 0) {
         $avg_rate = round($count / count($reviews));
     } else {
         $avg_rate = 0;
     }
     if ($flag) {
         return $avg_rate;
     }
     return $avg_rate . "/5 | " . count($reviews) . " " . Yii::t('easyii', 'reviews');
 }
Ejemplo n.º 2
0
 public function actionView($slug = null)
 {
     //echo $slug.'dddddddd';die;
     $item = Catalog::get($slug);
     if (!$item) {
         throw new NotFoundHttpException('Item not found.');
     }
     //        $reviews= News::find()
     //            ->where("product_id = ".$item->id." and status=1")
     //            ->all();
     $reviews = News::items(['tags' => '', 'pagination' => ['pageSize' => 5]], "product_id = " . $item->id);
     $count = 0;
     foreach ($reviews as $review) {
         $count += $review->no_of_review;
     }
     $avg_rate = count($reviews) / $count;
     $avg_rate = round($avg_rate);
     //var_dump($reviews);die;
     return $this->render('view', ['item' => $item, 'addToCartForm' => new \app\models\AddToCartForm(), 'reviews' => $reviews]);
 }
Ejemplo n.º 3
0
 public function actionReview($slug = null, $review)
 {
     $item = Catalog::get($slug);
     if (!$item) {
         throw new NotFoundHttpException('Item not found.');
     }
     $Creview = \app\modules\reviews\models\News::find()->where('news_id=' . $review)->one();
     if ($Creview) {
         $this->view->params['metatitle'] = $Creview->title;
         $this->view->params['metaimage'] = "http://" . $_SERVER['SERVER_NAME'] . '/' . $item->image;
         $this->view->params['metadesc'] = $Creview->short;
     }
     $reviews = News::items(['tags' => '', 'pagination' => ['pageSize' => 5]], "product_id = " . $item->id);
     $count = 0;
     foreach ($reviews as $review) {
         $count += $review->no_of_review;
     }
     if ($count > 0) {
         $avg_rate = count($reviews) / $count;
     } else {
         $avg_rate = 0;
     }
     $avg_rate = round($avg_rate);
     //var_dump($reviews);die;
     return $this->render('view', ['item' => $item, 'addToCartForm' => new \app\models\AddToCartForm(), 'reviews' => $reviews, 'Creviews' => $Creview]);
 }