/**
  * Adds product to list of favorites.
  *
  * @param integer $productId
  * @return mixed
  * @throws ForbiddenHttpException
  * @throws NotFoundHttpException
  */
 public function actionAdd($productId)
 {
     if (!empty($productId)) {
         if (!Yii::$app->user->isGuest) {
             $model = new FavoriteProduct();
             $model->product_id = $productId;
             $model->user_id = Yii::$app->user->id;
             if ($model->save()) {
                 if (Yii::$app->request->isAjax) {
                     return Yii::t('shop', 'You have successfully added this product to favorites.');
                 } else {
                     Yii::$app->session->setFlash('success', Yii::t('shop', 'You have successfully added this product to favorites.'));
                 }
             } else {
                 if (Yii::$app->request->isAjax) {
                     return Yii::t('shop', 'Error has occurred.');
                 } else {
                     Yii::$app->session->setFlash('error', Yii::t('shop', 'Error has occurred.'));
                 }
             }
             return $this->redirect(Yii::$app->request->referrer);
         }
         throw new ForbiddenHttpException();
     } else {
         throw new NotFoundHttpException();
     }
 }