コード例 #1
0
 /**
  * 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());
     foreach ($collection as $item) {
         $item->setIsActive(true);
         $item->save();
     }
     $this->messageManager->addSuccess(__('A total of %1 record(s) have been enabled.', $collection->getSize()));
     /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
     $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
     return $resultRedirect->setPath('*/*/');
 }
コード例 #2
0
ファイル: FaqsList.php プロジェクト: TheFrankman/magento2-faq
 /**
  * @return \Fc\Faqs\Model\ResourceModel\Faq\Collection
  */
 public function getFaqs()
 {
     // Check if faqs has already been defined
     // makes our block nice and re-usable! We could
     // pass the 'faqs' data to this block, with a collection
     // that has been filtered differently!
     /**
      * @todo check sort order is doing as it should
      * May need to be FaqInterface::SORT_ORDER_DESC
      */
     if (!$this->hasData('faqs')) {
         $faqs = $this->_faqCollectionFactory->create()->addFilter('is_active', 1)->addOrder(FaqInterface::SORT_ORDER, FaqCollection::SORT_ORDER_ASC);
         $this->setData('faqs', $faqs);
     }
     return $this->getData('faqs');
 }