I'm using magento C.E 1.7. I need to write a new module for table rate shipping, since I want to overwrite the already existing table rate shipping as per my requirement.

I need to change Tablerate.php in the following path.. app\code\core\Mage\Shipping\Model\Carrier\Tablerate.php

How can I do it?

1 Answer 1


First, celebrate that the Magento framework allows you to do this. It's a cool feature!

Next you need to check that this class is not directly referenced. This includes direct instantiation (i.e. new Mage_Shipping_Model_Carrier_Tablerate) as well as being subclassed; if any other class extends this class then your rewrite either won't work or will work inconsistently depending on direct usage of this class.

If the class is instantiated directly, subclassed, or if you prefer not to use Magento's class rewrite mechanism, then you can copy the path and file under the app/code/local/ codepool and make your changes there. The caveat of this approach is that when you upgrade you will need to merge changes from the definition under the core codepool into your local definition.

If you want to do a proper rewrite then you need to specify the following in some configuration XML:


This configuration should be in your own module's configuration XML. The caveat here though is that if any other custom module is also trying to perform the rewrite, you will have to set a dependency and extend your rewritten class from the other module's rewriting class.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.