/** * Execute action * * @return \Magento\Backend\Model\View\Result\Redirect * @throws \Magento\Framework\Exception\LocalizedException|\Exception */ public function execute() { $collection = $this->filter->getCollection($this->collectionFactory->create()); $collectionSize = $collection->getSize(); foreach ($collection as $block) { $block->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('*/*/'); }
protected function _getCollection() { $collection = $this->tabsCollectionFactory->create(); $storeId = $this->_storeManager->getStore()->getId(); return $collection->addOrder(EntityInterface::SORT_ORDER, TabsCollection::SORT_ORDER_DESC)->addStatusFilter(TabsModel::STATUS_ENABLED)->addStoreFilter($storeId); }