Magento 错误调用非对象上的成员函数 setCollection()
我的 Magento 有问题。当我登录并查看我的订单页面时,显示以下错误:
致命错误:在第 58 行对 C:\wamp\www\danfemall\app\code\core\Mage\Sales\Block\Order\History.php 中的非对象调用成员函数 setCollection()< /p>
当我删除从代码中删除 setCollection
函数,它运行良好,但我想知道 setCollection
函数的作用是什么,以及从代码中删除该函数是否明智。
请有人帮助我。
I have a problem with my Magento. When I login and view my orders page, the following error is shown:
Fatal error: Call to a member function setCollection() on a non-object in C:\wamp\www\danfemall\app\code\core\Mage\Sales\Block\Order\History.php on line 58
When I remove the setCollection
function from the code, it runs well but I wonder what the setCollection
function does and is it wise to remove that function from the code.
Please someone help me out.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Magento 版本号在调试 Mangeto 问题时总是有帮助的。另外,android(你的标签)适合在哪里?
假设以下行是给您的系统带来麻烦的行,
Magento 正在尝试创建一个
page/html_pager
块对象(假设没有覆盖,则对应于 Mage_Page_Block_Html_Pager)。在工作系统中,这是通过以下调用完成的。
它返回 Block 对象,然后调用 Block 的 setCollection 方法。
但是,在您的系统中,createBlock 方法没有返回对象,我猜测它返回的是布尔值。看一下 Layout 类的 createBlock 方法的开头。
因此,您的系统已被更改或配置为尝试创建
page/html_pager
块会引发异常。检查您的 Magento 异常日志以查看记录了哪些类型的错误,或者只是暂时放入var_dump
至于此代码的作用以及它将如何影响您的系统,
setCollection< /code> 方法将一个集合对象(类似于模型对象的数组)添加到您的 Block 对象中。如果没有集合,您的寻呼机块将(很可能)无法正确呈现。
Magento version numbers always help when debugging Mangeto problems. Also, where does android (your tag) fit in?
Assuming the following line is the one that's causing you trouble on your system
Magento is trying to create a
page/html_pager
block object (which, assuming no overrides are in place, corresponds to a Mage_Page_Block_Html_Pager).In a working system, that's done with the following call.
which returns the Block object, and then the setCollection method of the Block is called
However, in your system, the createBlock method isn't returning an object, and my guess is it's returning a boolean. Take a look at the start of the Layout class's createBlock method.
So, your system's been altered or is configured in such a way that attempts to create the
page/html_pager
block are throwing an exception. Check your Magento exception log to see what kind of errors are being logged, or just temporarily drop in avar_dump
As far as what this code does and how it will affect your system, the
setCollection
method adds a collection object (an array like object of models) to your Block object. Without a collection, your pager block will (most likely) not render correctly.