Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Delete.php
Go to the documentation of this file.
1 <?php
8 
11 
13 {
19  public function execute()
20  {
21  if ($rateId = $this->getRequest()->getParam('rate')) {
23  $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
24  try {
25  $this->_taxRateRepository->deleteById($rateId);
26 
27  $this->messageManager->addSuccess(__('You deleted the tax rate.'));
28  return $resultRedirect->setPath("*/*/");
29  } catch (NoSuchEntityException $e) {
30  $this->messageManager->addError(
31  __('We can\'t delete this rate because of an incorrect rate ID.')
32  );
33  return $resultRedirect->setPath("tax/*/");
34  } catch (\Magento\Framework\Exception\LocalizedException $e) {
35  $this->messageManager->addError($e->getMessage());
36  } catch (\Exception $e) {
37  $this->messageManager->addError(__('Something went wrong deleting this rate.'));
38  }
39 
40  if ($this->getRequest()->getServer('HTTP_REFERER')) {
41  $resultRedirect->setRefererUrl();
42  } else {
43  $resultRedirect->setPath("*/*/");
44  }
45  return $resultRedirect;
46  }
47  }
48 }
__()
Definition: __.php:13