filter = $filter; $this->collectionFactory = $collectionFactory; parent::__construct($context); } protected function _isAllowed() { return $this->_authorization->isAllowed('FME_Banners::banners'); } /** * Execute action * * @return \Magento\Backend\Model\View\Result\Redirect * @throws \Magento\Framework\Exception\LocalizedException|\Exception */ public function execute() { $status = $this->getRequest()->getParam('status'); $collection = $this->filter->getCollection($this->collectionFactory->create()); foreach ($collection as $item) { $item->setStatus($status); $item->save(); } $this->messageManager->addSuccess(__('A total of %1 record(s) have been changed.', $collection->getSize())); /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); return $resultRedirect->setPath('*/*/'); } }