2

In my custom module, while setting sql_setup i got this error,

Can't retrieve entity config: membership/members"

Error Report:

a:5:{i:0;s:163:"Error in file: "C:\xampp\htdocs\ems\app\code\local\Att\Membership\sql\membership_setup\mysql4-install-1.0.0.php" - Can't retrieve entity config: membership/members";i:1;s:908:"#0 C:\xampp\htdocs\ems\app\code\core\Mage\Core\Model\Resource\Setup.php(645): Mage::exception('Mage_Core', 'Error in file: ...')
1 C:\xampp\htdocs\ems\app\code\core\Mage\Core\Model\Resource\Setup.php(421):
Mage_Core_Model_Resource_Setup->_modifyResourceDb('install', '', '1.0.0')
2 C:\xampp\htdocs\ems\app\code\core\Mage\Core\Model\Resource\Setup.php(327):
Mage_Core_Model_Resource_Setup->_installResourceDb('1.0.0')
3 C:\xampp\htdocs\ems\app\code\core\Mage\Core\Model\Resource\Setup.php(235):
Mage_Core_Model_Resource_Setup->applyUpdates()
4 C:\xampp\htdocs\ems\app\code\core\Mage\Core\Model\App.php(417): Mage_Core_Model_Resource_Setup::applyAllUpdates()
5 C:\xampp\htdocs\ems\app\code\core\Mage\Core\Model\App.php(343): Mage_Core_Model_App->_initModules()
6 C:\xampp\htdocs\ems\app\Mage.php(683): Mage_Core_Model_App->run(Array)
7 C:\xampp\htdocs\ems\index.php(93): Mage::run('', 'store')
8 {main}";s:3:"url";s:5:"/ems/";s:11:"script_name";s:14:"/ems/index.php";s:4:"skin";s:7:"default";}

config file:

 <models>
        <membership>
            <class>Att_Membership_Model</class>
            <resoursemodel>membership_mysql4</resoursemodel>
        </membership>
        <membership_mysql4>
             <class>Att_Membership_Model_Mysql4</class>
             <entities>
                 <members>
                   <table>membership</table>
                 </members>
              </entities>
        </membership_mysql4>
    </models>
    <resources>
        <membership_setup>
            <setup>
                <module>Att_Membership</module>
            </setup>
            <connection>
                <use>core_setup</use>
            </connection>
        </membership_setup>
        <membership_write>
            <connection>
                <use>core_write</use>
            </connection>
        </membership_write>
        <membership_read>
            <connection>
                <use>core_read</use>
            </connection>
        </membership_read>
    </resources>

controller file:

 class Att_Membership_indexController extends
 Mage_Core_Controller_Front_Action{

 public function viewAction(){
 $params = $this->getRequest()->getParams();
 $prefs = Mage::getModel('membership/members');
 echo ("Loading the blogpost with an Id of " . $params['id']);
 $prefs->load($params['id']);
 $data = $prefs->getData();
 var_dump($data);
 } }

mysql setup file : mysql4-install-1.0.0.php

$installer = $this;
$installer->startSetup();
$installer->run("
DROP TABLE IF EXISTS {$installer->getTable('membership/members')};
CREATE TABLE {$installer->getTable('membership/members')} (
memberid int(11) NOT NULL auto_increment,
name text,
type text,
date datetime default NULL,
timestamp timestamp NOT NULL default CURRENT_TIMESTAMP,
PRIMARY KEY (memberid)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ");
$installer->endSetup();

models file:

class Att_Membership_Model_Members extends Mage_Core_Model_Abstract{
public function _construct(){
$this->_init('membership/members');
} }

class Att_Membership_Model_Mysql4_Members extends Mage_Core_Model_Mysql4_Abstract{
public function _construct(){
$this->_init('membership/members','memberid');
} }

2 Answers 2

6

First of all check if your table name is correct

<table>membership</table>

Also you have syntax error in resource model definition

<resoursemodel>membership_mysql4</resoursemodel>

resourceModel - word "model" should start with capital letter (i.e. Model).

<resourceModel>membership_mysql4</resourceModel>

After changes clear cache.

1
  • 1
    Thanks a lot oleksii, After changing <resoursemodel>membership_mysql4</resoursemodel> to <resourceModel>membership_mysql4</resourceModel> its work well
    – Helphin
    Commented Feb 10, 2014 at 9:55
0

I got this error when my class name wasn't the same with the last part of the name from my custom table.

Example:

class name was: Mynamespace_Mymodule_Model_Resource_Order and my table was mynamespace_mymodule_orders, so I changed my model, my resource model and the collection model into Mynamespace_Mymodule_Model_Resource_Orders.

I posted this, maybe will help someone. Thnx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.