Example #1
0
 /**
  * @param $slug
  * @return string
  * @throws NotFoundHttpException
  */
 public function actionView($slug)
 {
     $product = Catalog::product($slug);
     if (!$product) {
         throw new NotFoundHttpException();
     }
     $comment = new Comment();
     if (!\Yii::$app->user->isGuest && $comment->load(\Yii::$app->request->post())) {
         $comment->user_id = \Yii::$app->user->id;
         $comment->status = Comment::STATUS_ACTIVE;
         $product->model->link('comments', $comment);
     }
     $wishListModel = new AddToWishListForm();
     $wishList = WishList::get();
     if ($wishListModel->load(\Yii::$app->request->post())) {
         $wishList->add($product->model->id);
     }
     $category = Catalog::cat($product->model->category_id);
     return $this->render('view', ['product' => $product, 'category' => $category, 'wishListModel' => $wishListModel, 'inWishList' => $wishList->has($product->model->id)]);
 }
Example #2
0
 /**
  * @return string
  */
 public function actionIndex()
 {
     return $this->render('index', ['page' => Shop::page(Pages::WISH_LIST), 'wishList' => WishList::get()]);
 }