2

I am trying to overwrite the controller located at: app/core/code/Mage/Adminhtml/controllers/Catalog/ProductController.php

First of all I tried just making a copy in my local code directory app/local/code/Mage/Adminhtml/controllers/Catalog/ProductController.php keeping the file exactly the same and just making it die() so I knew if it was getting executed. But this didn't work and I read somewhere that you can't simply just drop an admin controller into the local directory.

Considering this, my next option is to write a module and use the config.xml to "rewrite" the controller. Thankfully I am able to add the functionality I require to a module that I have already been working on so I don't need to create a module simply for this task. So in my config.xml I added:

<config>

    ....

    <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <Mycompany_Prime before="Mage_Adminhtml">Mycompany_Prime_Adminhtml</Mycompany_Prime>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>

    .....

<admin/> is a direct child of <config/>.

Then I created my new controller under app/code/local/Mycompany/Prime/controllers/Adminhtml/ProductController.php with:

require_once "Mage/Adminhtml/controllers/Catalog/ProductController.php";

class Mycompany_Prime_Adminhtml_ProductController extends Mage_Adminhtml_Catalog_ProductController {

....

However the class never gets executed. For that matter, neither does the script:

die('Here');
require_once "Mage/Adminhtml/controllers/Catalog/ProductController.php";

class Mycompany_Prime_Adminhtml_ProductController extends Mage_Adminhtml_Catalog_ProductController {

Any help on overwriting this admin controller would be appreciated. I am using Magento version 1.6

lloiacono
  • 3,386
  • 21
  • 40
beingalex
  • 727
  • 2
  • 11
  • 25

1 Answers1

1

Your controller should be placed in the file app/code/local/Mycompany/Prime/controllers/Adminhtml/Catalog/ProductController.php instead of app/code/local/Mycompany/Prime/controllers/Adminhtml/ProductController.php.

Change the class name accordingly also.

Marius
  • 197,939
  • 53
  • 422
  • 830