0

I read a lot of answers of how to override models like:

app/code/core/Mage/Checkout/Model/Cart.php

And i don't know if i did something wrong but if i tried the same with:

app/code/core/Mage/Sales/Model/Config/Ordered.php

It doesn't works. I have:

config.xml
    <global>
        <models>
            <sales>
                <model>
                    <config>
                        <rewrite>
                            <ordered>Name_Example_Sales_Model_Config_Ordered</ordered>
                        </rewrite>
                    </config>
                </model>
            </sales>
        </models>
    </global>

and in app/code/local/Name/Example/Model/Config/Ordered.php:

class Name_Example_Sales_Config extends Mage_Sales_Model_Config_Ordered
{
    protected function _getSortedCollectorCodes()
    {

I don't know what the correct structure of the path or the xml.

1

Any Abstract class cannot not be override.

If,you want modify any thing then just copy this model to app/code/local directory...

As Mage_Sales_Model_Config_Ordered want to overwrite.

So Copy Ordered.php from app/code/core/Mage/Sales/Model/Config/ to

app/code/local/Mage/Sales/Model/Config/ .

As Magento logic: magento have taken file from local folder(app/code/local/) then

from app/code/core/.

  • But, what's happend with the patchs?, it'will be applied to the core and never change my local – characterError Jul 4 '17 at 14:12
  • For this you have to modified manually if any patches will update this file in core file. – Sumil sanghavi Jul 4 '17 at 14:14
  • extending core via copied files to local namespace is really a bad idea. It is best to find another way. – ProxiBlue Jul 5 '17 at 1:20
0

To rewrite a checkout/cart model :

app/etc/modules/Namespace_Namemodule.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Namespace_Namemodule>
            <active>true</active>
            <codePool>local</codePool>
            <depends>
                <Mage_Checkout />
            </depends>
        </Namespace_Namemodule>
    </modules>
</config>

app/code/local/Namespace/Namemodule/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Namespace_Namemodule>
            <version>0.0.1</version>
        </Namespace_Namemodule>
    </modules>
    <global>
        <models>
            <checkout>
                <rewrite>
                    <cart>Namespace_Namemodule_Model_Cart</cart>
                <rewrite>
            </checkout>
        </models>
    </global>
</config>

app/code/local/Namespace/Namemodule/Model/Cart.php

<?php
    class Namespace_Namemodule_Model_Cart extends Mage_Checkout_Model_Cart {

        public function test() {
            // your logic here
        }
    }
  • This was not the question ;) – sv3n Jul 4 '17 at 19:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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