Magento – Overwrite community Model file

moduleoverrides

I use the extension by raveinfosys to export orders from Magento.

I changed some stuff in the ordering of the items, but I do not want to do this in the extension itself. I want to do it with an own module.

The file is located in:

/app/code/community/Raveinfosys/Exporter/Model/Exportorders.php

In the config.xml of that module, I can only find this item which is related to a Model:

<models>
            <exporter>
                <class>Raveinfosys_Exporter_Model</class>
                <resourceModel>exporter_mysql4</resourceModel>
            </exporter>
            <exporter_mysql4>
                <class>Raveinfosys_Exporter_Model_Mysql4</class>
                <entities>
                    <exporter>
                        <table>exporter</table>
                    </exporter>
                </entities>
            </exporter_mysql4>
        </models>

I can not find something related to Exportorders.php, but how do I have to modify my own config.xml to overwrite the current Exportorders.php?

Thanks!

Best Answer

You can rewrite a community model just like a core model.
Create your extension and add this in the config.xml inside the global tag

<models>
    <exporter>
         <rewrite>
             <exportorders>[Namespace]_[Module]_Model_Exportorders</exportorders>
         </rewrite>
    </exporter>
</models>

then create your file [Namespace]/[Module]/Model/Exportorders.php with your code.

Here is a tutorial that explains how to rewrite a model

Related Topic