/** * _beforeToHtml method * * @return $this * @throws \Magento\Framework\Exception\LocalizedException */ protected function _beforeToHtml() { $provider = $this->config->getValue('socialquestions/general/provider'); if ($provider === 'facebook') { $this->setTemplate('facebook.phtml'); } elseif ($provider === 'disqus') { $this->setData('disqusid', $this->config->getValue('socialquestions/general/disqusid')); $this->setTemplate('disqus.phtml'); } else { // Remove tab $this->getLayout()->unsetElement('socialquestions.tab'); } return parent::_beforeToHtml(); }
/** * Need use as _prepareLayout - but problem in declaring collection from * another block (was problem with search result) * @return $this */ protected function _beforeToHtml() { $toolbar = $this->getToolbarBlock(); // called prepare sortable parameters $collection = $this->_getProductCollection(); // use sortable parameters $orders = $this->getAvailableOrders(); if ($orders) { $toolbar->setAvailableOrders($orders); } $sort = $this->getSortBy(); if ($sort) { $toolbar->setDefaultOrder($sort); } $dir = $this->getDefaultDirection(); if ($dir) { $toolbar->setDefaultDirection($dir); } $modes = $this->getModes(); if ($modes) { $toolbar->setModes($modes); } // set collection to toolbar and apply sort $toolbar->setCollection($collection); $this->setChild('toolbar', $toolbar); $this->_eventManager->dispatch('catalog_block_product_list_collection', ['collection' => $this->_getProductCollection()]); $this->_getProductCollection()->load(); return parent::_beforeToHtml(); }
/** * Before rendering html process * Prepare items collection * * @return \Magento\Catalog\Block\Product\ProductList\Crosssell */ protected function _beforeToHtml() { $this->_prepareData(); return parent::_beforeToHtml(); }
/** * Prepare collection with new products * * @return \Magento\Framework\View\Element\AbstractBlock */ protected function _beforeToHtml() { $this->setProductCollection($this->_getProductCollection()); return parent::_beforeToHtml(); }