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
7 
11 
13 {
17  public function execute()
18  {
20  $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
21  if ($this->getRequest()->getParam('id') > 0) {
22  try {
24  $model = $this->_objectManager->create(\Magento\Review\Model\Rating::class);
25  $model->load($this->getRequest()->getParam('id'))->delete();
26  $this->messageManager->addSuccess(__('You deleted the rating.'));
27  } catch (\Exception $e) {
28  $this->messageManager->addError($e->getMessage());
29  $resultRedirect->setPath('review/rating/edit', ['id' => $this->getRequest()->getParam('id')]);
30  return $resultRedirect;
31  }
32  }
33  $resultRedirect->setPath('review/rating/');
34  return $resultRedirect;
35  }
36 }
__()
Definition: __.php:13