Magento – Resource is not set


After being stumped for a little while and not finding any solutions by googling, I write these blog posts to share my findings. In order for a Magento model to find it’s resource, the config.xml and constructors with the init method are both needed. The name of the magento module in the init methods needs to match for the model to find it’s resource.

class Company_Mymodule_Model_Mysql4_Myentity extends Mage_Core_Model_Mysql4_Abstract {
public function _construct() {
$this->_init(‘mymodule/myentity’, ‘entity_id’);
}
}

class Company_Mymodule_Model_MyEntity extends Mage_Core_Model_Abstract {
public function _construct() {
parent::_construct();
$this->_init(‘mymodule/myentity’);
}
}

config.xml

Company_Mymodule_Model
mymodule_mysql4

Company_Mymodule_Model_Mysql4

my_entity

Advertisements

One thought on “Magento – Resource is not set

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s