Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Magento Models Overriding

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 102
    Comment on it

    In this tutorial, i will explain how to override magento models using an XML- based configuration file. Models play an important role as they connect our application to database & implement most of the business logic.
    we should not change any core files to implement custom features because it is a bad programming if core files are modified. So, what we will do is, create a new module called My_Pant and then we will perform our task to override.

    Lets start by creating the following folders to create custom module (Pant):
    app/code/local/My/Pant/etc
    app/code/local/My/Pant/Model

    Create config.xml file of custom module.
    Path: "app/code/local/Namespace/Modulename/etc/config.xml" and paste the following contents in that file.

    //Our namespace is My & modulename  is Pant

    <config>
      <global>
    
     <models>
    
           <checkout>
    
            <rewrite>
    
                 <cart>My_Pant_Model_Cart</cart>
    
            </rewrite>
    
           </checkout>
    
     </models>
    
     </global>
    
    </config>

    Now, create a Model file "app/code/local/My/Pant/Model/Cart.php" and paste the following contents in that file.

    class My_Pant_Model_Cart extends Mage_Checkout_Model_Cart
    
    {
    
    // override code in new class
    
    }

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: