Example #1
0
 /**
  * To option array
  *
  * @return array
  */
 public function toOptionArray()
 {
     if (!$this->options) {
         $this->options = $this->collectionFactory->create()->toOptionIdArray();
     }
     return $this->options;
 }
Example #2
0
 /**
  * Get Demo Items Collection
  * @return DemoCollection
  */
 public function getDemoItems()
 {
     if (null === $this->_demoCollection) {
         $this->_demoCollection = $this->_demoColFactory->create();
     }
     return $this->_demoCollection;
 }
Example #3
0
 /**
  * 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('*/*/');
 }