15

I encountered the following issue when i was trying to install a module. When I try to access the admin panel on my magento I get:

Call to a member function setActive() on boolean in C:\xampp\htdocs\project\vendor\magento\module-backend\Model\View\Result\Page.php on line 27

I disabled all third party and custom modules, I compiled the code but I still get this error.

EDIT: I did a var_dump($itemId) just below the line where the error is and the $itemid is 'Magento_Backend::dashboard'.

EDIT 2: The error is because the line "$this->layout->getBlock('menu');" above returns false. I can't find though why this is happening

1

6 Answers 6

25

I will try this to solve problem if setActive() error() arrived after setup:di:compile then becauese of session is destroy.

So go to Magento directory and then delete file generated by di:compile is path :-

magento\generated\metadata\global.php delete this file then after refersh your page.

This is temporary solution for this error in local server.

6
  • I already removed it and still not working. Aug 29, 2018 at 5:07
  • It actually worked for me, however, is it safe to remove this file?
    – Greg
    Dec 8, 2018 at 21:00
  • yes it's safe to remove as long as you do a setup:upgrade afterwards
    – John
    Jan 21, 2019 at 7:27
  • This worked for me. Thanks. May 27, 2019 at 6:30
  • This worked for me as well. Feb 6, 2020 at 10:42
8

I had the same situation in the development of own modules (I created/changed layout files for grid in adminhtml). Try to clean cache and switch to development mode:

$ ./bin/magento cache:clean
$ ./bin/magento deploy:mode:set developer

I suppose some cached stuff is not cleaned on cache:clean & setup:di:compile in production mode. You can switch back to production mode back if error will gone in development mode.

2
  • I think I did the same thing! It was a layout file issue. Thanks! Feb 7, 2018 at 9:06
  • 2
    php bin/magento setup:di:compile - executed this command and resolved my issue Aug 28, 2018 at 10:14
2

Do try to remove pub/static and var/cache then run the below commands

php bin/magento setup:upgrade

php bin/magento setup:static-content:deploy

After that it will work

1
  • 1
    @Priyank I was in the same situation, I google it and find that question on google, once I got to resolve the issue, I taught its better to share the solution. Maybe you just dislike because you need some badge or something else.
    – Noni
    Oct 23, 2018 at 11:55
2

The problem is that the layout xml of this controller path is not loading properly.

Check that the name and the namespace of the controller is matching with the layout file name. Take care of the case sensitivity.

For example:

  • custom_module_admin_customcontroller_action.xml
  • namespace Custom\Module\Controller\Adminhtml\Customcontroller and not CustomController
0

When you do getBlock() it returns the block or it returns false if it can not find it. You need to have a check in place something like :

$block = $layout->getBlock('name);
If ($block){
//execute the rest
}

The reason why it can not find your block is something i would need more details for. If you are using a layout xml file be sure that the block and the class of the block does not have any errors.

0

Temporary Fix : Remove "generated\metadata\global.php" and it will fix.

Permanent Fix : The problem is that the layout xml of this controller path is not loading properly.

Check that the name and the namespace of the controller is matching with the layout file name. Take care of the case sensitivity.

For example:

custom_module_admin_customcontroller_action.xml Check the namespace of the Controller Properly

Custom\Module\Controller\Adminhtml\Customcontroller

and not

Custom\Module\Controller\Adminhtml\CustomController

Your Answer

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

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