When I try to open Catalog->Categories in the backend, I get the following error:
Fatal error: Uncaught Error: Call to a member function getId() on null in /var/www/src/vendor/magento/framework/Data/Tree/Dbp.php:380 Stack trace:
#0 /var/www/src/vendor/magento/module-catalog/Block/Adminhtml/Category/AbstractCategory.php(167): Magento\Framework\Data\Tree\Dbp->loadEnsuredNodes(Object(Magento\Catalog\Model\Category\Interceptor), NULL)
#1 /var/www/src/vendor/magento/module-catalog/Block/Adminhtml/Category/AbstractCategory.php(120): Magento\Catalog\Block\Adminhtml\Category\AbstractCategory->getRoot()
#2 /var/www/src/vendor/magento/module-catalog/Block/Adminhtml/Category/Edit/SaveButton.php(25): Magento\Catalog\Block\Adminhtml\Category\AbstractCategory->hasStoreRootCategory()
#3 /var/www/src/vendor/magento/framework/View/Element/UiComponent/Context.php(268): Magento\Catalog\Block\Adminhtml\Category\Edit\SaveButton->getButtonData()
#4 /var/www/src/vendor/magento/module-ui/Component/AbstractComponent.php(116): Magento\Framework\View\Element\UiComponent\Context->addButtons(Array, Object(Magento\Ui\Component\Form in /var/www/src/vendor/magento/framework/Data/Tree/Dbp.php on line 380
Debugging had the following results so far:
- $rootNode in
src/vendor/magento/framework/Data/Tree/Dbp.php:380
is null - $tree->getNodeById($rootId) in
src/vendor/magento/module-catalog/Block/Adminhtml/Category/AbstractCategory.php:167
returns an empty tree ($rootId =1)
I found a similar problem for Magento 1: https://stackoverflow.com/questions/25527086/fatal-error-call-to-a-member-function-getid-on-a-non-object-in-c-wamp-www-ma
The database has current values:
INSERT INTO `catalog_category_entity` (`row_id`, `entity_id`, `created_in`, `updated_in`, `attribute_set_id`, `parent_id`, `created_at`, `updated_at`, `path`, `position`, `level`, `children_count`)
VALUES
(1, 1, 1, 2, 0, 0, '2017-11-04 12:26:53', '2019-05-06 11:27:09', '1', 0, 0, 1),
(2, 2, 1, 2, 3, 1, '2017-11-04 12:26:53', '2017-11-04 12:26:53', '1/2', 1, 1, 0);
INSERT INTO `catalog_category_entity_int` (`value_id`, `attribute_id`, `store_id`, `row_id`, `value`)
VALUES
(1, 69, 0, 1, 1),
(2, 46, 0, 2, 1),
(3, 69, 0, 2, 1);
INSERT INTO `catalog_category_entity_varchar` (`value_id`, `attribute_id`, `store_id`, `row_id`, `value`)
VALUES
(1, 45, 0, 1, 'Root Catalog'),
(2, 45, 0, 2, 'Default Category');
eav_attribute
- 45 = name
- 46 = is_active
- 69 = include_in_menu
Does anybody know how to fix this?