Fatal error in magento admin part add category

I encountered one error in the Magento Admin part. When I try to create a category, it shows the following fatal error:

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

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'); 

So can someone help me? How to fix these problems? can anyone suggest me a solution?

+3
source share
3 answers

Run this SQL query and it should clear it directly :)

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 directory'), (2, 3,33,0,1, "root directory") , (3,3,31,0,2, "Default Category"), (4,3,39,0,2, "PRODUCTS"), (5,3,33,0,2 'default category ');

+6
source

Ugh. Debugging the main code. I have to do this all the time.

Put a catch attempt on this code and error_log. This will give you a better idea of ​​which line has the problem. Check your php log for results

 public function loadEnsuredNodes($category, $rootNode) { try { $pathIds = $category->getPathIds(); $rootNodeId = $rootNode->getId(); $rootNodePath = $rootNode->getData($this->_pathField); $select = clone $this->_select; $select->order($this->_table.'.'.$this->_orderField . ' ASC'); } catch (Exception $e) { error_log($e); } 

If the error persists, try using the code in a sandbox. Create a test.php file and put it in the magento root.

 <?php umask(0); require_once 'app/Mage.php'; Mage::app('admin'); echo "<PRE>"; $category_id = 12; $rootNode = ??? load a root node what is this? $category = Mage::getModel('catalog/category')->load($category_id); var_dump($category->debug()); $pathIds = $category->getPathIds(); var_dump($pathIds); $rootNodeId = $rootNode->getId(); var_dump($rootNodeId); 

etc.

0
source

This answer

 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'); 

Helped me, thanks for saving my day! ... but I had a table prefix in my database, so getting it to wear change ... all I'm belive 3 "INSERT INTO catalog_category_entity" with "INSERT INTO _add_your_database prefix here_catalog_category_entity

and it should work ... anyway big thanx for help!

0
source

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


All Articles