無効なメソッドcustom_abc_model_custom :: magento ce 1.9.2のAddFieldToFilter管理パネル
-
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();
}
.
これは私のモデル
ですモデル/ custom.php
class Custom_ABC_Model_Custom extends Mage_Core_Model_Abstract
{
public function _construct()
{
parent::_construct();
$this->_init('custom_abc/custom');
}
}
.
モデル/リソース/ 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');
}
}
.
モデル/リソース/カスタム/ 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);
. 所属していません magento.stackexchange