我在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');
那么有人可以帮助我吗?如何解决这个问题?有谁能建议我解决方案?
答案 0 :(得分:6)
运行此SQL查询,它应该立即清理它:)
INSERT INTO catalog_category_entity
(entity_id
,entity_type_id
,attribute_set_id
,parent_id
,created_at
,updated_at
,{{1 }},path
,POSITION
,level
)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 /',1,1,0);
INSERT INTO children_count
(catalog_category_entity_int
,value_id
,entity_type_id
,attribute_id
,store_id
,entity_id
)价值观(1,3, 32,0,2,1),(2,3,32,1,2,1);
INSERT INTO value
(catalog_category_entity_varchar
,value_id
,entity_type_id
,attribute_id
,store_id
,entity_id
)价值观(1,3, 31,0,1,'根目录'),(2,3,33,0,1,'根目录'),(3,3,31,0,2,'默认类别'),(4, 3,39,0,2, '产品'),(5,3,33,0,2, '默认类别');
答案 1 :(得分:0)
UGH。核心代码调试。我必须一直这样做。
尝试捕获该代码并error_log结果。它可以让您更好地了解哪一行存在问题。检查你的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 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);
等
答案 2 :(得分: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');
帮助我,为了节省我的一天!...但我的数据库中有一个表格前缀
不要为任何人工作
改变...所有我相信3“INSERT INTO catalog_category_entity”
与"INSERT INTO _add_your_database prefix here_catalog_category_entity
它应该有用......无论如何都要大于帮助!