public function actionRemove($productId)
    {
        if (!empty($productId)) {
            if (!Yii::$app->user->isGuest) {
                $model = FavoriteProduct::find()
                    ->where(['product_id' => $productId, 'user_id' => Yii::$app->user->id])->one();
                if (!empty($model)) {
                    $model->delete();
                    if (Yii::$app->request->isAjax) {
                        return Yii::t('shop', 'You have successfully deleted this product from favorites.');
                    }
                    else {
                        Yii::$app->session->setFlash('success', Yii::t('shop', 'You have successfully deleted this product from 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();
    }
public function actionRemove($productId)
    {
        if (!empty($productId)) {
            if (!Yii::$app->user->isGuest) {
                $model = FavoriteProduct::find()
                    ->where(['product_id' => $productId, 'user_id' => Yii::$app->user->id])->one();
                if (!empty($model)) {
                    $model->delete();
                    if (Yii::$app->request->isAjax) {
                        return Yii::t('shop', 'You have successfully deleted this product from favorites.');
                    }
                    else {
                        Yii::$app->session->setFlash('success', Yii::t('shop', 'You have successfully deleted this product from 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();
    }
public function actionRemove ( $ productId ) { if ( ! empty ( $ productId ) ) { if ( ! Yii :: $ app -> user -> isGuest ) { $ model = FavoriteProduct :: find ( ) -> where ( [ 'product_id' => $ productId , 'user_id' => Yii :: $ app -> user -> id ] ) -> one ( ) ; if ( ! empty ( $ model ) ) { $ model -> delete ( ) ; if ( Yii :: $ app -> request -> isAjax ) { return Yii :: t ( 'shop' , 'You have successfully deleted this product from favorites.' ) ; } else { Yii :: $ app -> session -> setFlash ( 'success' , Yii :: t ( 'shop' , 'You have successfully deleted this product from 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 ( ) ; }
Removes product from list of favorites.

@param integer $productId
@return mixed
@throws ForbiddenHttpException
@throws NotFoundHttpException
Removes product from list of favorites .