/** * Prepare posts collection * * @return void */ protected function _preparePostCollection() { $this->_postCollection = $this->_postCollectionFactory->create()->addActiveFilter()->addStoreFilter($this->_storeManager->getStore()->getId())->setOrder('publish_time', 'DESC'); if ($this->getPageSize()) { $this->_postCollection->setPageSize($this->getPageSize()); } }
/** * @param string $name * @param string $primaryFieldName * @param string $requestFieldName * @param CollectionFactory $postCollectionFactory * @param DataPersistorInterface $dataPersistor * @param array $meta * @param array $data */ public function __construct($name, $primaryFieldName, $requestFieldName, CollectionFactory $postCollectionFactory, DataPersistorInterface $dataPersistor, array $meta = [], array $data = []) { $this->collection = $postCollectionFactory->create(); $this->dataPersistor = $dataPersistor; parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data); $this->meta = $this->prepareMeta($this->meta); }
/** * Construct * * @param string $name * @param string $primaryFieldName * @param string $requestFieldName * @param CollectionFactory $collectionFactory * @param RequestInterface $request * @param array $meta * @param array $data */ public function __construct($name, $primaryFieldName, $requestFieldName, CollectionFactory $collectionFactory, RequestInterface $request, array $meta = [], array $data = []) { parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data); $this->collection = $collectionFactory->create(); $this->request = $request; }
/** * Retrieve post collection with frontend filters and order * @return bool */ protected function _getFrontendCollection() { $collection = $this->_postCollectionFactory->create(); $collection->addActiveFilter()->addFieldToFilter('post_id', ['neq' => $this->getPost()->getId()])->addStoreFilter($this->_storeManager->getStore()->getId())->setOrder('publish_time', 'DESC')->setPageSize(1); return $collection; }