コード例 #1
0
 /**
  * @return \Credevlabz\Testimonials\Model\ResourceModel\Testimonial\Collection
  */
 public function getTestimonials()
 {
     if (!$this->hasData('testimonials')) {
         $testimonials = $this->_testimonialCollectionFactory->create()->addFilter('is_active', 1)->addOrder(TestimonialInterface::CREATION_TIME, TestimonialCollection::SORT_ORDER_DESC);
         $this->setData('testimonials', $testimonials);
     }
     return $this->getData('testimonials');
 }
コード例 #2
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());
     $collectionSize = $collection->getSize();
     foreach ($collection as $item) {
         $item->delete();
     }
     $this->messageManager->addSuccess(__('A total of %1 testimonial(s) have been deleted.', $collectionSize));
     /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
     $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
     return $resultRedirect->setPath('*/*/');
 }