I have this error message:
Fatal error: Call to a member function load() on a non-object in /home/autoco/public_html/shop/app/code/core/Mage/Core/Model/Abstract.php on line 225
How to fix this?
1.0.0
Becker_Tec_Model
tec_resource
Becker_Tec_Model_Resource
tof_manufacturers
Becker_Tec
tecdoc
Model class:
class Becker_Tec_Model_Manufacturers extends Mage_Core_Model_Abstract
{
protected function _construct()
{
$this->_init('tec/manufacturers');
}
public function test(){
$this->getCollection()->load(15);
}
}
Resource class:
class Becker_Tec_Model_Resource_Manufacturers extends Mage_Core_Model_Resource_Db_Abstract {
protected function _construct()
{
$this->_init('tec/manufacturers', 'tof_manufacturers_id');
}
}
Test Page:
require_once("app/Mage.php");
Mage::app();
$data = Mage::getModel("tec/manufacturers");
$data->load(136);
print_r($data);
Answer
Was the culprit as it didn't recognize how to hook up your call.
First of all use the same naming convention to avoid driving yourself mad.
Config xml model section:
Becker_Tec_Model
becker_tec_resource
Becker_Tec_Model_Resource
becker_tec
Model Class:
class Becker_Tec_Model_Tec extends Mage_Core_Model_Abstract
{
protected function _construct()
{
$this->_init( 'becker_tec/tec' );
}
Resource class:
class Becker_Tec_Model_Tec_Resource_Tec extends Mage_Core_Model_Resource_Db_Abstract
{
protected function _construct()
{
$this->_init( 'becker_tec/tec', 'entity_id' );
}
Collection class: ( If you want to use built in collection mechanisms )
class Becker_Tec_Model_Tec_Resource_Tec_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
{
public function _construct()
{
parent::_construct();
$this->_init( 'becker_tec/tec' );
}
Place them in the appropriate folders and you'll be able to call:
$oTec = Mage::getModel( 'becker_tec/tec' );
No comments:
Post a Comment