【问题标题】: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致命错误:在 C:\wamp\www\magentno\lib\Varien\Data\Tree\Dbp.php 第 332 行的非对象上调用成员函数 getId()
【发布时间】:2014-10-21 00:49:06
【问题描述】:

我正在使用 Magento 1.8.0.0, 我通过 localhost 在 WAMP 服务器上安装了一个测试版本,当我想添加类别时,我收到下一个错误:

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

我还没有开店,因为我需要分类。

我已经在给出错误的行中添加了一个 try and catch 代码。

这是给出错误的代码:

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

这条线是杀手:

 $rootNodeId = $rootNode->getId();

【问题讨论】:

  • 您的类别是 NULL,所以在非对象 (NULL) 上使用 -&gt; 会引发致命错误。如果您希望我们帮助您进行调试,您应该添加代码。
  • 我现在要添加代码
  • $root Node 是什么? $root Node 为 NULL。
  • @Debflav:这是 magento 核心文件。
  • 代码是dbp.php文件

标签: php magento magento-1.8


【解决方案1】:

由于重新索引问题而出现此问题。你可以运行这个查询来解决这个问题

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

注意:- 答案取自This Link

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-06-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多