getRequest()->getParam('id'); $model = $this->_objectManager->get('Magento\CheckoutAgreements\Model\Agreement')->load($id); if (!$model->getId()) { $this->messageManager->addError(__('This condition no longer exists.')); $this->_redirect('checkout/*/'); return; } try { $model->delete(); $this->messageManager->addSuccess(__('You deleted the condition.')); $this->_redirect('checkout/*/'); return; } catch (\Magento\Framework\Exception\LocalizedException $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError(__('Something went wrong while deleting this condition.')); } $this->getResponse()->setRedirect($this->_redirect->getRedirectUrl($this->getUrl('*'))); } }