1

To get block in magento1 we use echo $this->getLayout()->createBlock('module/adminhtml_module_grid')->toHtml().

What is the similar function in magento2?

1

You can do the same in Magento2 If your Block class extends Magento\Framework\View\Element\Template

$block->getLayout()->createBlock('something/something')->toHtml()

If your Block class does not extend Magento\Framework\View\Element\Template then you can Inject the \Magento\Framework\View\LayoutInterface in your block construct and you can use use this pattern.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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