1

So I have this module named Thatcompany_Module, and it has some admin controllers. I'm trying to override one of these controllers with my custom module, named Mycompany_MyModule

This is what the original routers section looks like in Thatcompany_Module :

<config>
    <admin>
        <routers>
            <modulefrontname>
                <use>admin</use>
                <args>
                    <module>Thatcompany_Module</module>
                    <frontName>modulefrontname</frontName>
                </args>
            </modulefrontname>
            <adminhtml>
                <args>
                    <modules>
                        <ThatCompany_Module before="Mage_Adminhtml">ThatCompany_Module_Adminhtml</ThatCompany_Module>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>
</config>

What I've done yet, following advices found here and there on the Internet :

My config :

<config>
    <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <Mycompany_MyModule before="Thatcompany_Module">Mycompany_MyModule_Adminhtml</Mycompany_MyModule>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>
</config>

And my controller :

<?php
include_once('Thatcompany/Module/controllers/Adminhtml/TheControllerName.php');

class Mycompany_MyModule_Adminhtml_TheControllerName extends Thatcompany_Module_Adminhtml_TheControllerName
{
    // [...]
}

Unfortunately, this is not working (I placed a big dirty die() in both index() actions, and the "Thatcompany" one displays instead of mine)

Any help, hint, link will be highly appreciated !

4
  • Can you post how the routers config section looks for the original module?
    – Marius
    Jan 16, 2014 at 9:39
  • Hi Marius, I edited my post to add the original routers section Jan 16, 2014 at 9:53
  • Hmmm...the code looks ok to me.
    – Marius
    Jan 16, 2014 at 10:04
  • Also seems ok to me. But obviously, I missed something... Jan 16, 2014 at 10:16

1 Answer 1

2

Ok I finally made it working (one of my coworkers, actually. Many thanks to him !). Problem was on the xml config. Here is the good one :

<config>
    <admin>
        <routers>
            <modulefrontname>
                <args>
                    <modules>
                        <Mycompany_MyModule before="Thatcompany_Module">Mycompany_MyModule</Mycompany_MyModule>
                    </modules>
                </args>
            </modulefrontname>
        </routers>
    </admin>
</config>

As you can see, I had to :

  • Change from <adminhtml> route to <modulefrontname> (because THIS is the route I needed to override)
  • Remove the _Adminhtml in the node value (and I have no idea why... If someone can explain...)
7
  • The first two things are used to find your module in app/code/<community|local>/Mycompany/Mymodule everything there after is suffixed after adding controllers to the path, so if you controller lives in MyModule/controllers/Adminhtml, add it, if not, don't add it :-) Jan 16, 2014 at 12:40
  • This is the point : my controller does live in MyModule/controllers/Adminhtml. This is why I'm confused about this solution ! Jan 16, 2014 at 13:03
  • is your path domain.com/module/adminhtml_controller/action ? Jan 16, 2014 at 13:03
  • Yes it is ! Is this the reason ? Jan 16, 2014 at 13:40
  • 2
    Correct. If you add Adminhtml to the config, you can remove it from the url. It must somehow be added to the controller path or the controller is not found ;) Jan 16, 2014 at 14:00

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.