1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright © Getnet. All rights reserved. |
4
|
|
|
* |
5
|
|
|
* @author Bruno Elisei <[email protected]> |
6
|
|
|
* See LICENSE for license details. |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace Getnet\SubSellerMagento\Controller\Adminhtml\Subseller; |
10
|
|
|
|
11
|
|
|
use Magento\Framework\App\Action\HttpPostActionInterface; |
12
|
|
|
use Magento\Framework\Controller\ResultFactory; |
13
|
|
|
use Magento\Framework\Exception\NoSuchEntityException; |
14
|
|
|
|
15
|
|
|
class Delete extends \Getnet\SubSellerMagento\Controller\Adminhtml\Subseller implements HttpPostActionInterface |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* Delete Rate and Data. |
19
|
|
|
* |
20
|
|
|
* @return \Magento\Backend\Model\View\Result\Redirect|void |
21
|
|
|
*/ |
22
|
|
|
public function execute() |
23
|
|
|
{ |
24
|
|
|
if ($subSellerId = $this->getRequest()->getParam('subseller')) { |
25
|
|
|
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ |
26
|
|
|
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); |
27
|
|
|
|
28
|
|
|
try { |
29
|
|
|
$this->_subSellerRepository->deleteById($subSellerId); |
30
|
|
|
|
31
|
|
|
$this->messageManager->addSuccess(__('You deleted the sub seller.')); |
|
|
|
|
32
|
|
|
|
33
|
|
|
return $resultRedirect->setPath('*/*/'); |
34
|
|
|
} catch (NoSuchEntityException $e) { |
35
|
|
|
$this->messageManager->addError( |
|
|
|
|
36
|
|
|
__('We can\'t delete this sub seller because of an incorrect sub seller ID.') |
37
|
|
|
); |
38
|
|
|
|
39
|
|
|
return $resultRedirect->setPath('subseller/*/'); |
40
|
|
|
} catch (\Magento\Framework\Exception\LocalizedException $e) { |
41
|
|
|
$this->messageManager->addError($e->getMessage()); |
|
|
|
|
42
|
|
|
} catch (\Exception $e) { |
43
|
|
|
$this->messageManager->addError(__('Something went wrong deleting this sub seller.')); |
|
|
|
|
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
if ($this->getRequest()->getServer('HTTP_REFERER')) { |
|
|
|
|
47
|
|
|
$resultRedirect->setRefererUrl(); |
48
|
|
|
} else { |
49
|
|
|
$resultRedirect->setPath('*/*/'); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
return $resultRedirect; |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.