tags:

views:

634

answers:

2

In the Magento Admin section, I want to override the "Sales/Order/ShipmentController.php" controller file of the core Mage.

I have tried rewriting the URL, using the "from" & "to" tags, but in vain.
I don't know what is the actual & correct way of doing this, as I'm a newbie in Magento.

Please anybody provide some good fundamental & correct answer, so that at least the concept gets clear.

Also, if possible, please tell me, what is the actual purpose of the controller, for both the frontend & the back-end?

Any help is greatly appreciated.

A: 

Not sure what you are talking about with "from" and "to" tags... What you need to do is write a simple custom module (the best way), or just override the controller by putting it in the /app/code/local/ directory.

[Edit] - I wrote a post that covers overriding the different Magento elements, controllers included: http://prattski.com/2010/06/24/magento-overriding-core-files-blocks-models-resources-controllers/

I hope that helps.

Prattski
This procedure is the most easiest of all, I agree.But what if I actually want to change the namespace, the module name, and the hierarchy of the core controller?For example, instead of the core Shipment controller file of the core Mage (as you pointed out), what if I wanted this "/app/code/local/Stack/Overflow/CustomController.php"?This is where I am stuck. Please help.
Knowledge Craving
If you follow the link I provided, that will tell you how to create your own module and override a controller. This will allow you to keep your code in app/code/local/your/code/If you want to create your own controller completely, it's a similar process. Just google for an article about creating your own module with a controller. There's plenty out there.
Prattski
Note that copying a core controller into local will not work. You can use this method to override Models and Blocks, but not controllers. You need to follow the wiki post with the rewrite rules.
Jonathan Day
+2  A: 

The correct method for overriding a controller is specified here : http://www.magentocommerce.com/boards/viewthread/16224/

The method of copying files from the core to local is not good. Doing so in this way means that you can only be sure that your custom module will work with the version of Magento that YOU are using. If you want the best chance of your module being compatible with other versions, it needs to be loosely coupled - extending and overriding the functions necessary for your purposes

Leesbian