0

I created a new module softcopy. and also created a new table with six fields of name softcopy_softcopy.

I am trying to access the table so that I can add a new row with some data which I have in controller.

So, I tried the below code in softcopy controller:

echo Mage::getResourceModel('catalog/product_collection')->getTable('softcopy/softcopy');

I got the following error in var/report:

a:5:{i:0;s:47:"Can't retrieve entity config: softcopy/softcopy";i:1;s:1469:"#0

How should I access my newly created table in my controller?

config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Efk_Softcopy>
            <version>1.0</version>
        </Efk_Softcopy>
    </modules>
    <frontend>
        <routers>            
            <Efk_Softcopy>
                <use>standard</use>
                <args>
                    <module>Efk_Softcopy</module>
                    <frontName>softcopy</frontName>
                </args>
            </Efk_Softcopy>
        </routers>
    </frontend>
    <global>
        <models>
            <softcopy>
                <class>Efk_Softcopy_Model</class>
            </softcopy>
        </models>
        <blocks>
            <softcopy>
                <class>Efk_Softcopy_Block</class>
            </softcopy>
        </blocks>
    </global>
</config>
2
  • can you post the config.xml of your module?
    – Marius
    Apr 11, 2014 at 7:47
  • @Marius updated post with config.xml.
    – Mr_Green
    Apr 11, 2014 at 7:50

1 Answer 1

1

You are missing the resource model declaration and the table declaration.
Change the <models> section of your config file to this:

<models>
    <softcopy>
        <class>Efk_Softcopy_Model</class>
        <resourceModel>softcopy_resource</resourceModel>
    </softcopy>
    <softcopy_resource>
        <class>Efk_Softcopy_Model_Resource</class>
        <entities>
            <softcopy>
                <table>softcopy_softcopy</table>
            </softcopy>
        </entities>
     </softcopy_resource>
</models>

You should also create a resource model for your model, and don't insert values directly in the db. Use the internal api:

Mage::getModel('softcopy/softcopy')->setData(...)->save();

I'm starting to feel like I'm spamming this website, but I recommend again using a module creator and you won't have these issues again

8
  • yeah I thought to use your module creator but thought I don't need much files here. but It seems I need them now.. thanks. I am checking now
    – Mr_Green
    Apr 11, 2014 at 8:05
  • Try first with what I suggested in the answer. Maybe it works and you don't need an additional tool anymore
    – Marius
    Apr 11, 2014 at 8:09
  • I mean no disrespect to you, module creator really helped alot in my project i.e more than 30%. but it creates some unnecessary files like .csv, .xml and .phtml which I don't need and also it creates a menu in admin panel and also a section in system->configuration.. I am getting scolds from my above people saying "why are you creating unnecessary sections?".. so, I thought to do it on my own by referring a module created using module creator... :)
    – Mr_Green
    Apr 11, 2014 at 8:26
  • NO problem. I understand that my module cannot fit everyone's needs, but in my opinion is easier to remove the unnecessary files than to build the same thing over and over again. Anyway...you know better what you need. :)
    – Marius
    Apr 11, 2014 at 8:35
  • The thing is I don't know which code to remove for unnecessary sections. your module creator is amazing though.. :)
    – Mr_Green
    Apr 11, 2014 at 8:41

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.