getRequest()->getParam('id'); if ($id) { try { $model = $this->_objectManager->create('Magento\SalesRule\Model\Rule'); $model->load($id); $model->delete(); $this->messageManager->addSuccess(__('You deleted the rule.')); $this->_redirect('sales_rule/*/'); return; } catch (\Magento\Framework\Exception\LocalizedException $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError( __('We can\'t delete the rule right now. Please review the log and try again.') ); $this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e); $this->_redirect('sales_rule/*/edit', ['id' => $this->getRequest()->getParam('id')]); return; } } $this->messageManager->addError(__('We can\'t find a rule to delete.')); $this->_redirect('sales_rule/*/'); } }