Fatal error: call getId () member function for non-object in C: \ wamp \ www \ magentno \ lib \ Varien \ Data \ Tree \ Dbp.php on line 332

I am working with Magento 1.8.0.0, I have a test version installed on the WAMP server through localhost, and when I want to add a category, I get the following error:

Fatal error: Call to a member function getId() on a non-object in C:\wamp\www\magentno\lib\Varien\Data\Tree\Dbp.php on line 332

I have not created a store yet, because for this I need a category.

I already added try and catch code to the line that gives the error.

this is the code that gives the error:

  public function loadEnsuredNodes($category, $rootNode) { $pathIds = $category->getPathIds(); $rootNodeId = $rootNode->getId(); $rootNodePath = $rootNode->getData($this->_pathField); $select = clone $this->_select; $select->order($this->_table.'.'.$this->_orderField . ' ASC'); if ($pathIds) { $condition = $this->_conn->quoteInto("$this->_table.$this->_idField in (?)", $pathIds); $select->where($condition); } $arrNodes = $this->_conn->fetchAll($select); if ($arrNodes) { $childrenItems = array(); foreach ($arrNodes as $nodeInfo) { $nodeId = $nodeInfo[$this->_idField]; if ($nodeId<=$rootNodeId) { continue; } $pathToParent = explode('/', $nodeInfo[$this->_pathField]); array_pop($pathToParent); $pathToParent = implode('/', $pathToParent); $childrenItems[$pathToParent][] = $nodeInfo; } $this->_addChildNodes($childrenItems, $rootNodePath, $rootNode, true); } } 

this line is a killer:

  $rootNodeId = $rootNode->getId(); 

i hope this image clears some stuff up

+5
source share
1 answer

This issue occurs because of a redefinition problem. You can run this query to solve this problem.

INSERT INTO catalog_category_entity(entity_id,entity_type_id,attribute_set_id,parent_id,created_at,updated_at,path,POSITION,level,children_count) VALUES (1,3,0,0,'0000-00-00 00:00:00','2009-02-20 00:25:34','1',1,0,1),(2,3,3,0,'2009-02-20 00:25:34','2009-02-20 00:25:34','1/2',1,1,0); INSERT INTO catalog_category_entity_int(value_id,entity_type_id,attribute_id,store_id,entity_id,value) VALUES (1,3,32,0,2,1),(2,3,32,1,2,1); INSERT INTO catalog_category_entity_varchar(value_id,entity_type_id,attribute_id,store_id,entity_id,value) VALUES (1,3,31,0,1,'Root Catalog'),(2,3,33,0,1,'root-catalog'),(3,3,31,0,2,'Default Category'),(4,3,39,0,2,'PRODUCTS'),(5,3,33,0,2,'default-category');

Note: The answer is from this link.

+1
source

Source: https://habr.com/ru/post/1201226/


All Articles