resultRedirectFactory->create(); // check if we know what should be deleted $id = $this->getRequest()->getParam('block_id'); if ($id) { try { // init model and delete $model = $this->_objectManager->create('Magento\Cms\Model\Block'); $model->load($id); $model->delete(); // display success message $this->messageManager->addSuccess(__('You deleted the block.')); // go to grid return $resultRedirect->setPath('*/*/'); } catch (\Exception $e) { // display error message $this->messageManager->addError($e->getMessage()); // go back to edit form return $resultRedirect->setPath('*/*/edit', ['block_id' => $id]); } } // display error message $this->messageManager->addError(__('We can\'t find a block to delete.')); // go to grid return $resultRedirect->setPath('*/*/'); } }