How to Rewrite Model in Magento?

Magento has multiple features, one of its best feature is modularity and possibility of overriding core classes.

We can rewrite model classes with the use of configuration file.

Here we will see how we can override Model with the custom module.

We are taking here Magento Customer Model  as an example to rewrite model.

Step 1 : We have to rewrite app/code/core/Mage/Customer/Model/Customer.php

Step 2 : Insert <rewrite> tag code in the file app/code/core/Mage/Customer/etc/config.xml as shown below


Step 3 : You need to activate custom module with following code in file app/code/local/Magik/Customer/etc/config.xml

                <Mage_Customer />

Step 4 : Now we have to create file app/code/local/Magik/Customer/Model/Customer.php as shown below.


class Magik_Customer_Model_Customer extends Mage_Customer_Model_Customer

// Override methods here with your own business logic


Step 5 : Done.

If you face any problems or need our professional services, please email us at [email protected]

Join our Newsletter

Never miss the latest offers, voucher codes and useful articles delivered weekly in your inbox.