public function actionDelete($id)
    {
        $product = Product::findOne($id);
        if (empty($product)) throw new NotFoundHttpException();

        if (\Yii::$app->user->can('deleteProduct', ['productOwner' => $product->owner])) {
            $this->trigger(self::EVENT_BEFORE_DELETE_PRODUCT);

            SeoData::deleteAll(
                ['AND',
                    ['entity_name' => ProductTranslation::className()],
                    ['in', 'entity_id', ArrayHelper::getColumn($product->translations, 'id')]]);

            $product->delete();

            $this->trigger(self::EVENT_AFTER_DELETE_PRODUCT, new ProductEvent(['id' => $id]));
            return $this->redirect('index');
        } else throw new ForbiddenHttpException(\Yii::t('shop', 'You have not permission to delete this product.'));
    }
public function actionDelete($id)
    {
        $product = Product::findOne($id);
        if (empty($product)) throw new NotFoundHttpException();

        if (\Yii::$app->user->can('deleteProduct', ['productOwner' => $product->owner])) {
            $this->trigger(self::EVENT_BEFORE_DELETE_PRODUCT);

            SeoData::deleteAll(
                ['AND',
                    ['entity_name' => ProductTranslation::className()],
                    ['in', 'entity_id', ArrayHelper::getColumn($product->translations, 'id')]]);

            $product->delete();

            $this->trigger(self::EVENT_AFTER_DELETE_PRODUCT, new ProductEvent(['id' => $id]));
            return $this->redirect('index');
        } else throw new ForbiddenHttpException(\Yii::t('shop', 'You have not permission to delete this product.'));
    }
public function actionDelete ( $ id ) { $ product = Product :: findOne ( $ id ) ; if ( empty ( $ product ) ) throw new NotFoundHttpException ( ) ; if ( \ Yii :: $ app -> user -> can ( 'deleteProduct' , [ 'productOwner' => $ product -> owner ] ) ) { $ this -> trigger ( self :: EVENT_BEFORE_DELETE_PRODUCT ) ; SeoData :: deleteAll ( [ 'AND' , [ 'entity_name' => ProductTranslation :: className ( ) ] , [ 'in' , 'entity_id' , ArrayHelper :: getColumn ( $ product -> translations , 'id' ) ] ] ) ; $ product -> delete ( ) ; $ this -> trigger ( self :: EVENT_AFTER_DELETE_PRODUCT , new ProductEvent ( [ 'id' => $ id ] ) ) ; return $ this -> redirect ( 'index' ) ; } else throw new ForbiddenHttpException ( \ Yii :: t ( 'shop' , 'You have not permission to delete this product.' ) ) ; }
Deletes product.

Users which have 'deleteProduct' permission can delete all Product models.
Users which have 'deleteOwnProduct' permission can delete only Product models that have been created by their.

@param integer $id
@return mixed
@throws ForbiddenHttpException
@throws NotFoundHttpException
Deletes product .