无效的方法custom_abc_model_custom :: AddFieldTofilter管理面板的Magento CE 1.9.2
-
29-09-2020 - |
题
在我的网格文件中筛选收集,但它显示错误。
这是我的网格文件的代码
protected function _prepareCollection() {
$custom_id = Mage::getSingleton('adminhtml/session')->getCustom()->getId();
$collection = Mage::getModel('custom_abc/custom')
->addFieldToFilter('custom_id',1)
->getCollection();
$adminStore = Mage_Core_Model_App::ADMIN_STORE_ID;
$store = $this->_getStore();
$this->setCollection($collection);
return parent::_prepareCollection();
}
.
这是我的型号
model / custom.php
class Custom_ABC_Model_Custom extends Mage_Core_Model_Abstract
{
public function _construct()
{
parent::_construct();
$this->_init('custom_abc/custom');
}
}
.
model /资源/ custom.php
class Custom_ABC_Model_Resource_Custom extends Mage_Core_Model_Resource_Db_Abstract
{
public function _construct()
{
$this->_init('custom_abc/custom', 'custom_id');
}
}
.
model /资源/自定义/ collection.php
class Custom_ABC_Model_Resource_Custom_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract{
protected function _construct()
{
parent::_construct();
$this->_init('custom_abc/custom');
}
}
. 解决方案
嗯,你只能应用
addFieldToFilter
一旦你收集,所以而不是这个:
$collection = Mage::getModel('custom_abc/custom')
->addFieldToFilter('custom_id',1)
->getCollection();
.
你应该做:
$collection = Mage::getModel('custom_abc/custom')
->getCollection()
->addFieldToFilter('custom_id',1);
.
也可能是:
$collection = Mage::getResourceModel('custom_abc/custom_collection')
->addFieldToFilter('custom_id',1);
.