ltsecurityinc安防产品在线商城代码
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
/**
|
||||
* @category JR
|
||||
* @package JR_NetSuite
|
||||
* @author JR Software Private Limited
|
||||
* @copyright Copyright (c) JR Software Private Limited (https://JR.com)
|
||||
* @license https://store.JR.com/license.html
|
||||
*/
|
||||
namespace JR\NetSuite\Controller\Adminhtml\RmaQueue;
|
||||
|
||||
use Magento\Framework\Controller\ResultFactory;
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Ui\Component\MassAction\Filter;
|
||||
use JR\NetSuite\Model\ResourceModel\RmaQueue\CollectionFactory;
|
||||
|
||||
class MassDelete extends \Magento\Backend\App\Action
|
||||
{
|
||||
/**
|
||||
* Massactions filter.
|
||||
*
|
||||
* @var Filter
|
||||
*/
|
||||
private $filter;
|
||||
|
||||
/**
|
||||
* @var CollectionFactory
|
||||
*/
|
||||
private $collectionFactory;
|
||||
|
||||
/**
|
||||
* @param Context $context
|
||||
* @param Filter $filter
|
||||
* @param CollectionFactory $collectionFactory
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Filter $filter,
|
||||
CollectionFactory $collectionFactory
|
||||
) {
|
||||
$this->filter = $filter;
|
||||
$this->collectionFactory = $collectionFactory;
|
||||
parent::__construct($context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute action
|
||||
*
|
||||
* @return \Magento\Backend\Model\View\Result\Redirect
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
$collection = $this->filter->getCollection($this->collectionFactory->create());
|
||||
$accountsCount = 0;
|
||||
foreach ($collection->getItems() as $account) {
|
||||
$this->deleteObj($account);
|
||||
++$accountsCount;
|
||||
}
|
||||
$this->messageManager->addSuccess(__('A total of %1 record(s) have been deleted.', $accountsCount));
|
||||
|
||||
return $this->resultFactory->create(ResultFactory::TYPE_REDIRECT)->setPath('*/*/index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete object.
|
||||
*
|
||||
* @param mixed $object
|
||||
* @return void
|
||||
*/
|
||||
private function deleteObj($object)
|
||||
{
|
||||
$object->delete();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user