2

in my Controller i call

 public function execute()
    {   

        $this->_view->loadLayout();
        echo $this->_view->getLayout()->getBlock('productquestion_edit_tab_answerquestion')->setTemplate('Mageaddons_Productquestion::answers/edit.phtml'); die('xxx');
        ..}

Get Fatal error: Call to a member function setTemplate() on boolean

1 Answer 1

0

This means that you do not have a block in the layout with name 'productquestion_edit_tab_answerquestion'.

Also _view property is deprecated, please use

 /** @var \Magento\Backend\Model\View\Result\Page $resultPage */
 $resultPage = $this->resultPageFactory->create();
 $resultPage->getLayout()->getBlock(...) 
1
  • For exmaple $resultPage = $this->resultPageFactory->create(); $resultPage->getLayout()->getBlock('checkout.cart.totals');. setTemplate() is not required Commented Apr 6, 2016 at 13:10

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.