I have stuck with this. I am trying to override sales/ order model _saveafter function with my custom module. I have the following code




class Rkt_SalesNew_Model_Order extends Mage_Sales_Model_Abstract


   protected function _afterSave()
    if (null !== $this->_addresses) {
        $billingAddress = $this->getBillingAddress();
        $attributesForSave = array();
        if ($billingAddress && $this->getBillingAddressId() != $billingAddress->getId()) {
            $attributesForSave[] = 'billing_address_id';

        $shippingAddress = $this->getShippingAddress();
        if ($shippingAddress && $this->getShippigAddressId() != $shippingAddress->getId()) {
            $attributesForSave[] = 'shipping_address_id';

        if (!empty($attributesForSave)) {
            $this->_getResource()->saveAttribute($this, $attributesForSave);

    if (null !== $this->_items) {
    if (null !== $this->_payments) {
    if (null !== $this->_statusHistory) {
    foreach ($this->getRelatedObjects() as $object) {
    return parent::_afterSave();


I am unable to override this function. Can any one please help me out.

2 Answers 2


You can rewrite abstract class just need to copy Mage_Sales_Model_Abstract file to community or local pool.

And after that, you can edit that file in that scope. autoload functionality will load files from following orders:
1. lib
2. core
3. community
4. local

app > code > community > Mage > Sales > Model > Abstract.php


_afterSave method is not defined in abstract class, it's in main Order class itself. Your config.xml file is wrong for rewrite declaration, it should be something like this (only relevant part added here ) :


And lastly, you'll be need to extend Mage_Sales_Model_Order class, not the abstract class.


Your Answer

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

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