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()); $delete = 0; foreach ($collection as $item) { /** @var \Smartwave\Dailydeals\Model\Dailydeal $item */ $item->delete(); $delete++; } $this->messageManager->addSuccess(__('A total of %1 record(s) have been deleted.', $delete)); /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT); return $resultRedirect->setPath('*/*/'); } }