filter = $filter; $this->collectionFactory = $collectionFactory; } /** * Execute action * * @return \Magento\Backend\Model\View\Result\Redirect * @throws \Magento\Framework\Exception\LocalizedException|\Exception */ public function execute() { try { $collection = $this->filter->getCollection($this->collectionFactory->create()); return $this->massAction($collection); } catch (\Exception $e) { $this->messageManager->addError($e->getMessage()); /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); return $resultRedirect->setPath($this->redirectUrl); } } /** * Return component referer url * TODO: Technical dept referer url should be implement as a part of Action configuration in appropriate way * * @return null|string */ protected function getComponentRefererUrl() { return $this->filter->getComponentRefererUrl()?: 'customer/*/index'; } /** * Execute action to collection items * * @param AbstractCollection $collection * @return ResponseInterface|ResultInterface */ abstract protected function massAction(AbstractCollection $collection); }