_initVariable(); /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultRedirectFactory->create(); if ($variable->getId()) { try { $variable->delete(); $this->messageManager->addSuccess(__('You deleted the custom variable.')); } catch (\Exception $e) { $this->messageManager->addError($e->getMessage()); return $resultRedirect->setPath('adminhtml/*/edit', ['_current' => true]); } } return $resultRedirect->setPath('adminhtml/*/'); } }