[英]Magento Fatal error: Call to a member function addFieldToFilter() on a non-object
I am attempting to override a model in a third party extension so I can add a few more columns to the database table it uses and manipulate them. 我试图覆盖第三方扩展中的模型,以便可以向它使用的数据库表中添加更多列并进行操作。 I've added the following in
config.xml
: 我在
config.xml
添加了以下内容:
<marketplace>
<rewrite>
<userprofile>ZeroBars_Marketplacepayment_Model_Userprofile</userprofile>
</rewrite>
</marketplace>
and copied the Userprofile.php
file into my module's Model folder. 并将
Userprofile.php
文件复制到我模块的Model文件夹中。 The code in Userprofile makes a call to the collection of the previous Model that I am overriding: Userprofile中的代码调用了我要覆盖的先前模型的集合:
public function getPartnerProfileById($partnerId) {
$data = array();
if ($partnerId != '') {
$collection = Mage::getModel('marketplace/userprofile')->getCollection();
$collection->addFieldToFilter('mageuserid',array('eq'=>$partnerId));
...
and I am now served with a Fatal Error
for calling addFieldToFilter
. 现在我因调用
addFieldToFilter
Fatal Error
。 I've tried copying over the files in Mysql4 as well but I am not sure how to go about adding an override for them in config. 我也尝试过复制Mysql4中的文件,但是我不确定如何在配置中为其添加替代。 How can I sleuth out what is going wrong?
我如何找出出了什么问题?
KRay, for get collection of table then you need Define Collection for that model KRay,要获取表集合,则需要为该模型定义Define Collection
I you need to class collection file of that module which is fetch all data of the table 我您需要对该模块的类收集文件进行分类,以获取表的所有数据
Collection file path is Collection.php app/code/yourcodePOol/your pakkage name/Modulename/Model/Resource/Userprofile/ 集合文件路径为Collection.php app / code / yourcodePOol /您的文件名/模块名称/模型/资源/用户配置文件/
<?php
class YourPackagename_Modulename_Model_Resource_Userprofile_Collection
extends Mage_Core_Model_Resource_Db_Collection_Abstract{
protected function _constuct(){
$this->_init('marketplace/userprofile');
}
}
If you using mysql4 as resource model then try 如果您使用mysql4作为资源模型,请尝试
<?php
class YourPackagename_Modulename_Model_Mysql4_Userprofile_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
{
public function _construct()
{
$this->_init('marketplace/userprofile');
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.