/** * Before block to html * * @return $this */ protected function _beforeToHtml() { $toolbar = $this->getToolbarBlock(); // called prepare sortable parameters $collection = $this->getPostCollection(); // set collection to toolbar and apply sort $toolbar->setCollection($collection); $this->setChild('toolbar', $toolbar); return parent::_beforeToHtml(); }
/** * Prepare posts collection * * @return void */ protected function _preparePostCollection() { $size = $this->getData('number_of_posts'); if (!$size) { $size = (int) $this->_scopeConfig->getValue('mfblog/sidebar/recent_posts/posts_per_page', \Magento\Store\Model\ScopeInterface::SCOPE_STORE); } $this->setPageSize($size); parent::_preparePostCollection(); if ($category = $this->getCategory()) { $categories = $category->getChildrenIds(); $categories[] = $category->getId(); $this->_postCollection->addCategoryFilter($categories); } }
/** * @return $this */ public function _construct() { $this->setPageSize((int) $this->_scopeConfig->getValue('mfblog/sidebar/' . $this->_widgetKey . '/posts_per_page', \Magento\Store\Model\ScopeInterface::SCOPE_STORE)); return parent::_construct(); }
/** * Prepare posts collection * * @return void */ protected function _preparePostCollection() { parent::_preparePostCollection(); $this->_postCollection->getSelect()->group('MONTH(main_table.publish_time)', 'DESC'); }
/** * Prepare posts collection * * @return void */ protected function _preparePostCollection() { parent::_preparePostCollection(); $this->_postCollection->addFieldToFilter('post_id', array('in' => $this->getPost()->getRelatedPostIds() ?: array(0)))->addFieldToFilter('post_id', array('neq' => $this->getPost()->getId()))->setPageSize((int) $this->_scopeConfig->getValue('mfblog/post_view/related_posts/number_of_posts', \Magento\Store\Model\ScopeInterface::SCOPE_STORE)); }