2

I am trying to override Mage_Sales_Model_Resource_Order_Collection

My custom module's config:

<?xml version="1.0" encoding="UTF-8"?>


<config>
    <modules>
        <Abc_Salesextend>
            <version>0.1.0</version>
        </Abc_Salesextend>
    </modules>

    <global>       
        <blocks>
            <salesextend>
                <class>Abc_Salesextend_Block</class>   
            </salesextend>  

            <adminhtml>
                <rewrite>
                    <sales_order_grid>Abc_Salesextend_Block_Sales_Order_Grid</sales_order_grid>
                </rewrite>                
            </adminhtml>    
        </blocks>

        <models>
            <salesextend>
                <class>Abc_Salesextend_Model</class>   
                <resourceModel>salesextend_resource</resourceModel> 
            </salesextend>

            <salesextend_resource>
                <class>Abc_Salesextend_Model_Resource</class>
            </salesextend_resource>

            <!-- HERE is i am trying to override-->

            <sales_resource>
                <rewrite>

                    <order_collection>Abc_Salesextend_Model_Resource_Order_Collection</order_collection>

                </rewrite>                
            </sales_resource>    
        </models>
    </global>

</config>

It's not giving me any kind of error even if I place the wrong custom class name. So it's not finding my custom class.

Please help

2
  • 2
    Your xml looks fine to me. Possible that is already rewritten by another 3rd party module? To check for rewrite conflicts, get this github.com/firegento/firegento-debug and check for rewrite conflicts
    – ProxiBlue
    Aug 12, 2013 at 6:45
  • @Proxiblue I have tried disabling all the extensions. And firegento is showing status ok for sales_resource/order_collection Aug 13, 2013 at 1:16

1 Answer 1

6

The single most important place to debug a Magento rewrite is right here

#File: app/code/core/Mage/Core/Model/Config.php
public function getGroupedClassName($groupType, $classId, $groupRootNode=null)
{
    //...    
    $config = $this->_xml->global->{$groupType.'s'}->{$group};

    // First - check maybe the entity class was rewritten
    $className = null;
    if (isset($config->rewrite->$class)) {
        $className = (string)$config->rewrite->$class;
    } else {
        /**
         * Backwards compatibility for pre-MMDB extensions.
         * In MMDB release resource nodes <..._mysql4> were renamed to <..._resource>. So <deprecatedNode> is left
         * to keep name of previously used nodes, that still may be used by non-updated extensions.
         */
        if ($config->deprecatedNode) {
            $deprecatedNode = $config->deprecatedNode;
            $configOld = $this->_xml->global->{$groupType.'s'}->$deprecatedNode;
            if (isset($configOld->rewrite->$class)) {
                $className = (string) $configOld->rewrite->$class;
            }
        }
    }

    //...
}

This is where Magento dives into your configuration to look for a rewrite node, and if it finds one, rewrite the class. Add some temporary conditional debugging code here that prints or logs the information Magento's fetching from the config and you'll get the bottom of most rewrite problems.

2
  • I checked using this but my custom class is not showing, all ohter over riding classes are showing from other modules. It is just not taking into account sale_resouce node or the deprecatedNode. Thats the weirdest thing I've come accross. I also tried disabling all the other modules in local. Still no luck. My xml in config and etc/module is also all correct Aug 13, 2013 at 5:12
  • @RIK when $group is equal to 'sale_resouce', what's the contents of $config->asXml()? Does the output of asXml include your rewrite XML? Aug 13, 2013 at 6:54

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.