I created route and admin menu item linked to this route, but I am getting the error message in the browser when I try to access it:

1 exception(s):
Exception #0 (Exception): Notice: Undefined property: Namespace\Mymodule\Controller\Adminhtml\Griglia\Index\Interceptor::$_resultPage in /Applications/MAMP/htdocs/magento2/app/code/Namespace/Mymodule/Controller/Adminhtml/Griglia/Index.php on line 34 ...... ............(MORE ERROR TEXT IS HERE) ....

I can see the content of the page on this route, if I cut the processing by outputting something in execute method and return;, but I want the template to load too, using the layout and template for this admin page.

Code in Controller/Adminhtmk/Griglia/Index.php is:


namespace Namespace\Mymodule\Controller\Adminhtml\Griglia;

class Index extends \Magento\Backend\App\Action
    protected $resultPageFactory = false;
    public function __construct(
        \Magento\Backend\App\Action\Context $context,
        \Magento\Framework\View\Result\PageFactory $resultPageFactory
    ) {
        $this->resultPageFactory = $resultPageFactory;

    public function execute()

        //Call page factory to render layout and page content
        return $this->getResultPage();

     * Check permission via ACL resource
    protected function _isAllowed()
        return $this->_authorization->isAllowed('Namespace_Mymodule::griglia');

    public function getResultPage()
        if (is_null($this->_resultPage)) {
            $this->_resultPage = $this->_resultPageFactory->create();
        return $this->_resultPage;

    protected function _setPageData()
        $resultPage = $this->getResultPage();

        return $this;

  • 1
    Post the code from Reply\Importinvoices\Controller\Adminhtml\Griglia\Index – Marius Mar 28 '17 at 12:50
  • Code added in question. – Vladimir Despotovic Mar 28 '17 at 12:53

Add this line above the constructor:

protected $_resultPage;

and in the method getResultPage replace this

$this->_resultPage = $this->_resultPageFactory->create();

with this

$this->_resultPage = $this->resultPageFactory->create();
| improve this answer | |

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.