Magento 版本号在调试 Mangeto 问题时总是有帮助的。另外,android(你的标签)在哪里适合?
假设以下行是导致您系统出现问题的行
$pager = $this->getLayout()->createBlock('page/html_pager', 'sales.order.history.pager')
->setCollection($this->getOrders());
Magento 正在尝试创建一个 page/html_pager 块对象(假设没有覆盖,对应于 Mage_Page_Block_Html_Pager)。
在工作系统中,通过以下调用完成。
$this->getLayout()->createBlock('page/html_pager', 'sales.order.history.pager')
返回Block对象,然后调用Block的setCollection方法
->setCollection($this->getOrders());
但是,在您的系统中,createBlock 方法没有返回对象,我猜它返回的是布尔值。看一下 Layout 类的 createBlock 方法的开头。
#File: app/code/core/Mage/Core/Model/Layout.php
public function createBlock($type, $name='', array $attributes = array())
{
try {
$block = $this->_getBlockInstance($type, $attributes);
} catch (Exception $e) {
Mage::logException($e);
return false;
}
因此,您的系统已被更改或配置为尝试创建 page/html_pager 块会引发异常。检查您的 Magento 异常日志以查看记录了哪些类型的错误,或者只是暂时放入 var_dump
try {
$block = $this->_getBlockInstance($type, $attributes);
} catch (Exception $e) {
var_dump($e->getMessage()); //don't forget to remove me before pushing
//to production
Mage::logException($e);
return false;
}
就这段代码的作用以及它将如何影响您的系统而言,setCollection 方法将一个集合对象(一个类似于模型对象的数组)添加到您的 Block 对象中。如果没有集合,您的寻呼机块将(很可能)无法正确呈现。