本文整理汇总了PHP中Magento\Catalog\Block\Product\AbstractProduct::_beforeToHtml方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractProduct::_beforeToHtml方法的具体用法?PHP AbstractProduct::_beforeToHtml怎么用?PHP AbstractProduct::_beforeToHtml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Catalog\Block\Product\AbstractProduct
的用法示例。
在下文中一共展示了AbstractProduct::_beforeToHtml方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _beforeToHtml
/**
* _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();
}
示例2: _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();
}
示例3: _beforeToHtml
/**
* Before rendering html process
* Prepare items collection
*
* @return \Magento\Catalog\Block\Product\ProductList\Crosssell
*/
protected function _beforeToHtml()
{
$this->_prepareData();
return parent::_beforeToHtml();
}
示例4: _beforeToHtml
/**
* Prepare collection with new products
*
* @return \Magento\Framework\View\Element\AbstractBlock
*/
protected function _beforeToHtml()
{
$this->setProductCollection($this->_getProductCollection());
return parent::_beforeToHtml();
}