public function actionChangeProductStatus($id, $status)
    {
        if (!empty($id) && !empty($status)) {
            $product = Product::findOne($id);
            if ($product->status == Product::STATUS_ON_MODERATION) {

                switch ($status) {
                    case Product::STATUS_SUCCESS:
                        $product->status = Product::STATUS_SUCCESS;
                        $product->save();

                        $this->trigger(self::EVENT_AFTER_ACCEPT_PRODUCT, new ProductEvent([
                            'id' => $id
                        ]));

                        break;
                    case Product::STATUS_DECLINED:
                        $product->status = Product::STATUS_DECLINED;
                        $product->save();
                        break;
                }

                $this->trigger(self::EVENT_AFTER_EDIT_PRODUCT, new ProductEvent([
                    'id' => $id
                ]));
            }
        }
        return $this->redirect(Yii::$app->request->referrer);
    }
public function actionChangeProductStatus($id, $status)
    {
        if (!empty($id) && !empty($status)) {
            $product = Product::findOne($id);
            if ($product->status == Product::STATUS_ON_MODERATION) {

                switch ($status) {
                    case Product::STATUS_SUCCESS:
                        $product->status = Product::STATUS_SUCCESS;
                        $product->save();

                        $this->trigger(self::EVENT_AFTER_ACCEPT_PRODUCT, new ProductEvent([
                            'id' => $id
                        ]));

                        break;
                    case Product::STATUS_DECLINED:
                        $product->status = Product::STATUS_DECLINED;
                        $product->save();
                        break;
                }

                $this->trigger(self::EVENT_AFTER_EDIT_PRODUCT, new ProductEvent([
                    'id' => $id
                ]));
            }
        }
        return $this->redirect(Yii::$app->request->referrer);
    }
public function actionChangeProductStatus ( $ id , $ status ) { if ( ! empty ( $ id ) && ! empty ( $ status ) ) { $ product = Product :: findOne ( $ id ) ; if ( $ product -> status == Product :: STATUS_ON_MODERATION ) { switch ( $ status ) { case Product :: STATUS_SUCCESS : $ product -> status = Product :: STATUS_SUCCESS ; $ product -> save ( ) ; $ this -> trigger ( self :: EVENT_AFTER_ACCEPT_PRODUCT , new ProductEvent ( [ 'id' => $ id ] ) ) ; break ; case Product :: STATUS_DECLINED : $ product -> status = Product :: STATUS_DECLINED ; $ product -> save ( ) ; break ; } $ this -> trigger ( self :: EVENT_AFTER_EDIT_PRODUCT , new ProductEvent ( [ 'id' => $ id ] ) ) ; } } return $ this -> redirect ( Yii :: $ app -> request -> referrer ) ; }
Changes product status property by ModerationManager

Users which have 'moderateProductCreation' permission can change product status.

@param integer $id
@param integer $status
@return mixed
Changes product status property by ModerationManager