Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I resolve a 'Resource is not set' error in magento?

Tags:

php

mysql

magento

I am trying to get a record from mysql database with Mage::getModel('amshuhucustomer/groupdomain')->load($id);

It is working with observer so no need for frontend in config.xml

But it is not loaded and saying 'Resource is not set'

module/etc/config.xml

<global>
    <models>
        <amshuhucustomer>
            <class>Amshuhu_Customer_Model</class>
            <resourceModel>amshuhucustomer_mysql4</resourceModel>
        </amshuhucustomer>
        <amshuhucustomer_mysql4>
            <class>Amshuhu_Customer_Model_Mysql4</class>
            <entities>
                <groupdomain>
                    <table>customergroupdomain</table>
                </groupdomain>
            </entities>
        </amshuhucustomer_mysql4>
    </models>
    <resources>
        <amshuhucustomer_setup>
            <setup>
                <module>Amshuhu_Customer</module>
                <class>Amshuhu_Customer_Model_Mysql4_Setup</class>
            </setup>
            <connection>
                <use>core_setup</use>
            </connection>
        </amshuhucustomer_setup>
        <amshuhucustomer_write>
            <connection>
                <use>core_write</use>
            </connection>
        </amshuhucustomer_write>
        <amshuhucustomer_read>
            <connection>
                <use>core_read</use>
            </connection>
        </amshuhucustomer_read>
    </resources>
......
</global>

Groupdomain.php

class Amshuhu_Customer_Model_Mysql4_Groupdomain extends Mage_Core_Model_Mysql4_Abstract
{
    protected function _construct()
    {
        $this->_init('amshuhucustomer/groupdomain', 'id');
    }
}
like image 507
Balaji Perumal Avatar asked Dec 13 '13 09:12

Balaji Perumal


1 Answers

Finally found the answer by myself.

Forget to add the initialization in the model itself.

Added the following in the _construct method solved the issue..

$this->_init('amshuhucustomer/groupdomain');
like image 152
Balaji Perumal Avatar answered Oct 15 '22 22:10

Balaji Perumal