gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:47:38 24 4
gpt4 key购买 nike

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

fatal error :在 C:\wamp\www\magentno\lib\Varien\Data\Tree\Dbp.php 中的非对象上调用成员函数 getId() 第 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);
}
}

这一行是 killer :

 $rootNodeId = $rootNode->getId();

i hope this image clears some stuff up

最佳答案

此问题是由于重建索引问题引起的。您可以运行此查询以解决此问题

INSERT INTO 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) VALUES (1,3,32,0,2,1),(2,3,32,1,2,1);插入 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,'默认类别'),(4,3,39,0,2,'产品'),(5,3,33,0,2,'默认类别');

注意:- 答案取自 This Link

关于php - 第 332 行的 fatal error : Call to a member function getId() on a non-object in C:\wamp\www\magentno\lib\Varien\Data\Tree\Dbp. php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25527086/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com