public function actionAddToCart($id) { $cart = new ShoppingCart(); $model = Product::findOne($id); if ($model) { $cart->put($model, 1); return $this->redirect(['cart-view']); } throw new NotFoundHttpException(); }