1

I try to follow this tutorial: http://devdocs.magento.com/guides/m1x/magefordev/mage-for-dev-5.html

Problem is it doesn't work at all as Magento always tries to load the model from the wrong folder

Warning: include(Mage/My/Module/Model/Resource/Blogpost.php)

Here is my config.xml. The part with overwriting the success page works like a charm.

<?xml version="1.0"?>
<config>
    <modules>
        <my_module>
            <version>1.0.0</version>
        </my_module>
    </modules>
    <frontend>
        <routers>
            <my_module>
                <use>standard</use>
                <args>
                    <module>My_Module</module>
                    <frontName>my_module</frontName>
                </args>
            </my_module>
        </routers>
        <layout>
            <updates>
                <my_module>
                    <file>module.xml</file>
                </my_module>
            </updates>
        </layout>
    </frontend>
    <global>
        <blocks>
            <my_module>
                <class>My_Module_Block</class>
            </my_module>
            <checkout>
                <rewrite>
                    <onepage_success>My_Module_Block_Onepage_Success</onepage_success>
                </rewrite>
            </checkout>
        </blocks>
    </global>
    <models>
        <my_module>
            <class>My_Module_Model</class>
            <resourceModel>my_module_resource</resourceModel>
        </my_module>
    </models>
</config>

2 Answers 2

1

Your <models> node needs to be inside the <global> node. Like you did for the <blocks> node:

<global>
        <blocks>
            <my_module>
                <class>My_Module_Block</class>
            </my_module>
            <checkout>
                <rewrite>
                    <onepage_success>My_Module_Block_Onepage_Success</onepage_success>
                </rewrite>
            </checkout>
        </blocks>
        <models>
            <my_module>
                <class>My_Module_Model</class>
                 <resourceModel>my_module_resource</resourceModel>
            </my_module>
        </models>
    </global>
1
  • Thanks, I followed so many tutorials (that didn't point this out) I missed the forest for the trees... -.-
    – steros
    Aug 1, 2016 at 9:49
1

Move :

<models>
    <my_module>
        <class>My_Module_Model</class>
        <resourceModel>my_module_resource</resourceModel>
    </my_module>
</models>

To, <global>

<global>
    <blocks>
        <my_module>
            <class>My_Module_Block</class>
        </my_module>
        <checkout>
            <rewrite>
                <onepage_success>My_Module_Block_Onepage_Success</onepage_success>
            </rewrite>
        </checkout>
    </blocks>
    <models>
        <my_module>
            <class>My_Module_Model</class>
            <resourceModel>my_module_resource</resourceModel>
        </my_module>
    </models>
</global>
4
  • this is similar answer as @Rahpael Aug 1, 2016 at 9:46
  • @QaisarSatti: may be we are both answering at same time. It's possible, right ?? : ) Aug 1, 2016 at 10:20
  • 2 minute difference between these two answer but maybe possible but try to not add identical answer. Aug 1, 2016 at 10:26
  • 2
    Sure, I'll. I was trying to provide answer with code. When I posted my answer, I also see the answer of Raphael (with single line, that says move models to global). After that he edited his answer with code that makes our both's answer similar. : ) Aug 1, 2016 at 10:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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