i have phtml file and i declare in theBlock\login.php as $_template = "phtml path, its working fine but not for MEQP2 its giving WARNING | Property name $_template should not be prefixed with an underscore to indicate visibility; when i remove the underscore with veriable of $template then magento view is not working. i already use the upgrade:setup command but not working fine. then what i do?

1 Answer 1


Use setTemplate()

protected function _construct()



  • This is automatic call when file is execute? Jul 20, 2018 at 6:10
  • @DhadukMitesh yes it is. Jul 20, 2018 at 9:15
  • If I replace the $_template line with this function, then it is working same. Right? Jul 20, 2018 at 9:16
  • @DhadukMitesh this function is used for showing the output so anything you write in this function will show as output. Jul 20, 2018 at 9:22
  • @QaisarSatti, How you have understand that you have to use protected function _tohtml() { $this->setTemplate("QaisarSatti_HelloWorld::helloworld.phtml"); return parent::_toHtml(); }
    – Amit Bera
    Nov 6, 2018 at 7:36

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.