I ran into this error
Fatal error: Call to a member function getId() on a non-object in /path/to/magento/lib/internal/Magento/Framework/View/Model/Layout/Merge.php on line 745
after loading a new system’s MySQL database into my local development environment. Magento 2’s theme settings allow you to pick a specific theme from a drop down menu. From a UI perspective, this is an improvement over Magento 1. However, it does mean that Magento now stores a theme’s ID in the core_config_data
table instead of a the raw string name. This, in turn, means Magento needs to load a theme object (from the theme
table). If Magento can’t find the theme path, it won’t load the object, which leads to this error.
To fix this — your backend should still be working. Just navigate to
Stores -> Configuration -> Design
and pick a new design theme. You can also try setting the value directly in core_config_data
under the path design/theme/theme_id
.