filter = $filter; $this->collectionFactory = $collectionFactory; } /** * @return \Magento\Framework\Controller\ResultInterface */ public function execute() { /** @var \Plumrocket\CookieConsent\Model\ResourceModel\Cookie\Collection $collection */ $collection = $this->filter->getCollection($this->collectionFactory->create()); $collectionSize = $collection->getSize(); foreach ($collection->getItems() as $cookie) { $cookie->delete(); } $this->messageManager->addSuccessMessage(__('A total of %1 record(s) have been deleted.', $collectionSize)); /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); return $resultRedirect->setPath('*/*/'); } }