3

我在 Magento Admin 部分面临一个错误,当我尝试创建一个类别时,它显示以下致命错误:

致命错误:在第 331 行的 C:\wamp\www\magento\lib\Varien\Data\Tree\Dbp.php 中的非对象上调用成员函数 getId()

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

那么任何人都可以帮助我吗?如何解决这个问题?谁能建议我解决方案?

4

3 回答 3

6

运行此 SQL 查询,它应该立即清理它:)

插入 catalog_category_entity( entity_id, entity_type_id, attribute_set_id, parent_id, created_at, updated_at, path, POSITION, level, children_count) 值 (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); 插入catalog_category_entity_int( value_id, entity_type_id, attribute_id, store_id, entity_id, value) 值 (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) 值 (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');

于 2013-06-13T00:30:18.533 回答
0

啊。核心代码调试。我必须一直这样做。

对该代码进行尝试捕获并错误记录结果。它会让您更好地了解哪条线路有问题。检查您的 php 日志以获取结果

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

如果错误仍然存​​在,则尝试在隔离环境中使用代码。创建一个文件 test.php 并将其放在 magento 根目录下。

<?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

于 2013-02-28T14:30:47.097 回答
0

这个答案

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

帮助了我,thanx 拯救了我的一天!...但是我的数据库中有一个表前缀,所以它不适合任何人更改...我相信 3“INSERT INTO catalog_category_entity”"INSERT INTO _add_your_database prefix here_catalog_category_entity

它应该可以工作......无论如何,感谢您的帮助!

于 2015-01-11T00:35:03.013 回答