<?php
/**
* Landofcoder
*
* NOTICE OF LICENSE
*
* This source file is subject to the Landofcoder.com license that is
* available through the world-wide-web at this URL:
* https://landofcoder.com/terms
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this extension to newer
* version in the future.
*
* @category Landofcoder
* @package Lof_MarketPlace
* @copyright Copyright (c) 2021 Landofcoder (https://www.landofcoder.com/)
* @license https://landofcoder.com/terms
*/
namespace Lof\MarketPlace\Controller\Adminhtml\Rating;
class Delete extends \Lof\MarketPlace\Controller\Adminhtml\Rating
{
/**
* Delete action
*
* @return \Magento\Backend\Model\View\Result\Redirect
*/
public function execute()
{
$id = $this->getRequest()->getParam('rating_id');
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultRedirectFactory->create();
if ($id) {
try {
$model = $this->_objectManager->create(\Lof\MarketPlace\Model\Rating::class);
$model->load($id);
$model->delete();
$this->messageManager->addSuccessMessage(__('The seller has been deleted.'));
return $resultRedirect->setPath('*/*/');
} catch (\Exception $e) {
$this->messageManager->addErrorMessage($e->getMessage());
return $resultRedirect->setPath('*/*/edit', ['rating_id' => $id]);
}
}
$this->messageManager->addErrorMessage(__('We can\'t find a seller to delete.'));
return $resultRedirect->setPath('*/*/');
}
/**
* {@inheritdoc}
*/
protected function _isAllowed()
{
return $this->_authorization->isAllowed('Lof_MarketPlace::rating_delete');
}
}
|