0

I try to overwrite the Exportorders.php in my extension which is located here:

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

I created my own extension now in /app/code/local/Namespace/Raveinfosys/Exporter/

and added the Namespace_Raveinfosys_Exporter.xml to /app/etc/modules/.

Within /Exporter/ I created two folders: /etc/ and /Model/. Within /etc/ I placed the config xml with the following contents:

<?xml version="1.0"?>
<config>
    <modules>
         <Namespace_Raveinfosys_Exporter>
            <version>0.0.1</version>
        </Namespace_Raveinfosys_Exporter>
    </modules>
    <global>
        <models>
            <raveinfosys_exporter>
                    <rewrite>
    <exportorders>Namespace_Raveinfosys_Exporter_Model_Exportorders</exportorders>
                    </rewrite>
            </raveinfosys_exporter>
        </models>
   </global>
</config>

Within the /Model/ folder I created copied the Exportorders.php and put in the first line:

class Namespace_Raveinfosys_Exporter_Model_Exportorders extends Raveinfosys_Exporter_Model_Exportorders

But somehow it is not working. Does anybody know why it is not working? Is it a problem that the /etc/ Folder are in the 2nd level? They are not in Namespace/Exporter, they are in Namespace/Raveinfosys/Exporter.

1
  • "Is it a problem that the /etc/ Folder are in the 2nd level?" - Yes
    – changeling
    Aug 3 '15 at 20:57
0

Magento expects modules to have the following structure:

Namespace/Modulename

Certain components of the module architecture (specifically controllers and etc contents must be in a specific hierarchy. Your module violates these expectations, and that's why it doesn't work.

Also, there are two general ways to change class behaviors (excluding event observers). The preferred way is a configured class rewrite, in which you designate a different class to instantiate when some other class is requested. The less-preferred way is to inject your own definition of a class via autoloading precedence (this can be done without creating a new module). You seem to be conflating the two with your solution.

1
  • Thanks - do you know a good resource that explains what you try to say in terms of these 2 ways? I do not know if I understood it completely. I now removed the second folder level "Exporter" from my extension and moved the /etc/ and /model/ folder to Namespace/Raveinfosys and changed the XML structure (I removed the exporter from there as well) but still my class in exportorders.php is not taken from Magento... do you have another hint for me? Would be great.
    – Torben
    Aug 6 '15 at 13:11

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.