/** * To option array * * @return array */ public function toOptionArray() { if (!$this->options) { $this->options = $this->collectionFactory->create()->toOptionIdArray(); } return $this->options; }
/** * Get Demo Items Collection * @return DemoCollection */ public function getDemoItems() { if (null === $this->_demoCollection) { $this->_demoCollection = $this->_demoColFactory->create(); } return $this->_demoCollection; }
/** * Execute action * * @return \Magento\Backend\Model\View\Result\Redirect */ public function execute() { $collection = $this->filter->getCollection($this->collectionFactory->create()); $collectionSize = $collection->getSize(); foreach ($collection as $item) { $item->delete(); } $this->messageManager->addSuccess(__('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('*/*/'); }