PHP致命错误:调用成员函数getSubCategories
我的店铺是用Prestashop 1.5.6.2构建的 在我的服务器上的错误日志文件中,我每天大约可以看到10次以下错误: PHP致命错误:在第551行的../controllers/front/ProductController.PHP中调用null上的成员函数getSubCategories() ProductController.php文件的第551行是:PHP致命错误:调用成员函数getSubCategories,php,prestashop-1.5,Php,Prestashop 1.5,我的店铺是用Prestashop 1.5.6.2构建的 在我的服务器上的错误日志文件中,我每天大约可以看到10次以下错误: PHP致命错误:在第551行的../controllers/front/ProductController.PHP中调用null上的成员函数getSubCategories() ProductController.php文件的第551行是: 'subCategories' => $this->category->getSubCategories($thi
'subCategories' => $this->category->getSubCategories($this->context->language->id, true),
此行是以下代码的一部分:
// various assignements before Hook::exec
$this->context->smarty->assign(array(
'path' => $path,
'category' => $this->category,
'subCategories' => $this->category->getSubCategories($this->context->language->id, true),
'id_category_current' => (int)$this->category->id,
'id_category_parent' => (int)$this->category->id_parent,
'return_category_name' => Tools::safeOutput($this->category->name),
'categories' => Category::getHomeCategories($this->context->language->id, true, (int)$this->context->shop->id)
));
我不是开发人员,我不知道是什么导致了这个错误
你知道是什么导致了这个错误吗
提前感谢您的回复
Patrick出现错误是因为在某些情况下未定义
$this->category
变量。您应该在代码
中添加一个条件来检查(第551行的controllers/front/ProductController.php)
替换以下内容:
'subCategories' => $this->category->getSubCategories($this->context->language->id, true),
与
查看该问题是否已解决。出现错误是因为在某些情况下未定义
$this->category
变量。您应该在代码
中添加一个条件来检查(第551行的controllers/front/ProductController.php)
替换以下内容:
'subCategories' => $this->category->getSubCategories($this->context->language->id, true),
与
查看问题是否已解决。此错误表示
$This->category
为空,检查此错误的可能重复表示$This->category
为空,检查此错误的可能重复非常感谢Knowband的最后建议。你的方法非常有效!非常感谢Knowband最后的建议。你的方法非常有效!