0

I need to call my custom class like below as it is done in magento 1x:

I need to Generate New Layered Navigation Menu

$viewPanel = $this->getLayout()->getBlock('catalog.leftnav')->toHtml(); 

$productList = $this->getLayout()->getBlock('product_list')->toHtml(); 

Should i use pageFactory like as:

$viewPanel= $resultPageFactory->getLayout()->createBlock('Vendor\Module\Block\Product\ListProduct');

Or use:

$viewPanel= $this->_view->getLayout()->createBlock('Tagalys\Tglcatalog\Block\Product\ListProduct');

and _view is from use Magento\Framework\View\LayoutInterface; ?

Which is correct way of calling ?

1

1 Answer 1

0

Recommended way to use $this->resultFactory. And yes, Magento itself use $this->_view but it's the old way, It was @deprecated too but when M2 GA available they just remove (@deprecated) from $this->_view.

For more information click here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.