1

I need my module folder structure like app/code/local/ABC/MyNameSpace/MyModule

edit

I am working on a project and client insist of overriding any module in local/ABC folder. If I want to override PQR_XYZ module, then it must be added as local/ABC/PQR_XYZ. There are many other modules overridden with this method but they only overrides models or blocks, and they all work fine.

Please find below code references. config.xml

<config>
    <modules>
        <ABC_Amasty_Shopby>
            <version>2.8.2.1</version>
        </ABC_Amasty_Shopby>
    </modules>
    <global>
        <blocks>
            <amshopby>
                <rewrite>
                    <top>ABC_Amasty_Shopby_Block_Top</top>
                </rewrite> 
            </amshopby>
        </blocks>
    </global>
</config>

My Block File is in:

app/code/local/ABC/Amasty/Shopby/Block/Top.php

This is working.

Now for overriding a controller, config.xml

<config>
    <modules>
        <ABC_Amazon_Payments>
            <version>1.3.0.1</version>
        </ABC_Amazon_Payments>
    </modules>
    <frontend>
        <routers>
            <amazon>
                <use>standard</use>
                <args>
                    <module>ABC_Amazon_Payments</module>
                    <frontName>abcamazon</frontName>
                </args>
            </amazon>
        </routers>
    </frontend>
    <global>
        <rewrite>        
            <ABC_amazon_payments_onepagecontroller>
                <from><![CDATA[#^/amazon_payments/onepage/#]]></from> <!-- Amazon_Payments_OnepageController  -->
                <to>/abcamazon/amazon_payments_onepage/</to> <!-- ABC_Amazon_Payments_OnepageController  -->
            </ABC_amazon_payments_onepagecontroller>
        </rewrite>
    </global>
</config>

My controller file:

app/code/local/ABC/Amazon/Payments/controllers/OnepageController.php

This is not working. I need to override a controller and for a controller, this structure is not working.

Is it possible?

  • 2
    no you can't .it must be {codePool}/{NameSpace}/{Module} – Minesh Patel Oct 16 '15 at 12:17
  • i am sure this is possible but don't know how. – John Oct 16 '15 at 12:21
  • I am VERY curious for what reason you want to do this. I think you have a problem and you think that this will be the solution... while probably there is a better solution to your initial problem. But then you so have to explain us your initial problem... – 7ochem Jan 15 '16 at 20:49
  • Hi @7ochem, I updated the question, please check. – John Jan 18 '16 at 7:00
  • @John what is the error that you're getting in case of controller rewrite ? please provide the exception or system logs – Rajeev K Tomy Jan 18 '16 at 7:04
1

You could do this by editing the file app/Mage.php. In this file, Magento sets the include paths here. But by doing this, you update the core and after each update, you'll have to change this back again.

But Magento also loads the get_include_path() from your system. So you might also want to add the folder there, but in that case, it will be added at the end of the include path. This means that if file MyNameSpace/MyModule/Block/Test.php also exists in app/code/community, app/code/local or lib, that file will be used in stead of your custom path.

But as 7ochem already said, why do you want to use this custom path? Even after editing your original question, I don't see a reason on why to do this.

  • You said that right. But from the feedback from OP, he is looking for a permanent solution and in that case eidting core file is highly discouraged. – Rajeev K Tomy Jan 18 '16 at 7:12
  • Editing the core is ALWAYS discouraged, so adding the path to the vhost's include path might be a better solution. But like I said, if the file exists in the app/code/community folder, Magento will load that file. – Arjen Miedema Jan 18 '16 at 7:16

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.