2
votes
  1. I want to create a model for a DB table called "contactform_contact_list"
  2. NameSpace is 'Chandan', ModuleName : 'Contactform'
  3. So, my app/code/local/Chandan/Contactform/etc/config.xml is like this :

like this:

<models>
 <contactform>
   <class>Chandan_Contactform_Model</class> 
   <resourceModel>contactform_resource</resourceModel>
 </contactform>
 <contactform_resource>
  <class>Chandan_Contactform_Model_Resource</class>
   <entities>
    <contactform>
     <table>contactform_contact_list/table>
    </contactform>
   </entities>
 </contactform_resource>
</models>
  1. app/code/local/Chandan/Contactform/controllers/IndexController's indexAction() is like this ::

    $contact = Mage::getModel("contactform/contact"); $contact->load($params['id']);

  2. app/code/local/Chandan/Contactform/Model/Contact.php is like this ::

    class Chandan_Contactform_Model_Contact extends Mage_Core_Model_Abstract { protected function _construct() { $this->_init('contactform/contact'); }

    }

  3. However, it is giving me this error : Can't retrieve entity config: chandan_contactform/contact

What I am missing here? Any help is highly appreciated.

1
I am trying to put, How can I put XML here? Not accepting the tagsuser3401141
please use {} (code Sample of editor)Amit Bera
I have found out the solution :: The tag "<contactform>" immediately after "<entities>" tag should be changed to "<contact>". This worked perfectly.user3401141

1 Answers

2
votes

Your class name is wrong and also model files path .

if you using Mage::getModel("contactform/contact"); then file structure should be

Chandan>Contactform>Model>Contact.php
Chandan>Contactform>Model>Resource>Contact.php
Chandan>Contactform>Model>Resource>Contact>Collection.php

Check the link

Also issue in is not closed.

  <class>Chandan_Contactform_Model_Resource/class>

to

<class>Chandan_Contactform_Model_Resource</class>