1

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?

0

In Magento Root Category ID is hard coded You have to update Root category Id if you deleted default one, Then tree will appears normally. Just change Root category Id constant variable defined in model

update these constant

Update these constants

  • I tried your workaround, but it didn't fixed the problem – Peter Horitzer May 7 at 8:16
  • 1
    Please don't add codes as image – fmsthird May 7 at 8:39
0

Problem was a combination of FireGento FastSimpleImport2 + Commerce Edition (Enterprise)

The column updated_in in the table catalog_category_entity of the root node (ID 1) is not updated correctly. Never touch the root node, but when you have an active B2B module-staging and you schedule a catalog price rule, the category view in adminhtml is broken. This is because the root node gets skipped out of the select statement when the category tree is loaded.

We temporary fixed this issue by manipulating the value of updated_in for the Category entities 1 and 2 to a very high level.

https://github.com/firegento/FireGento_FastSimpleImport2/issues/95

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.