Showing results for 
Search instead for 
Did you mean: 

How do I overwrite core functions?

How do I overwrite core functions?

Hi there


Been working on a big project with a bunch of modifications. For some of these modifications I have been overwriting core files but copying entire PHP classes/files from core to the local directory. But... I only want to overwrite one or two functions from these classes.


For example and in particular I want to overwite some functions of the admin order create class:


class Mage_Adminhtml_Model_Sales_Order_Create extends Varien_Object implements Mage_Checkout_Model_Cart_Interface 

From my limited knowledge in this area, I think I have to do something like



class my_new_class extends Mage_Adminhtml_Model_Sales_Order_Create

function function_to_overwrite(){}

But.... how I can implement this new class so that it runs to overwrite the core function?


Thanks in advance



Re: How do I overwrite core functions?


You can google how to rewrite model, block, to name just a few.
If you use PHPStorm editor, you should install Magicento Plugin. It will help you overwriting classes quickly.
We should use Observer to minimize our core customization.


In your example:

Your config xml should add:

<sales_order_create>Your_new_rewrite_class</sales_order_create> </rewrite> </adminhtml> </models>

You can create your new Model class under your Model folder, example: Model/Adminhtml/Sales/Order/Create.php

Problem solved? Click Accept as Solution!