Question

I'm trying to override the Mage_Adminhtml_Block_Sales_Order_Grid class, but no success with that.

My config.xml file:

<?xml version="1.0"?>
<config>
    <modules>
        <AD_Tweaks>
            <version>1.0.0</version>
        </AD_Tweaks>
    </modules>
    <global>
        <models>
            <catalog>
                <rewrite>
                    <product>AD_Tweaks_Catalog_Model_Product</product>
                </rewrite>
             </catalog>
         </models>
         <blocks>
             <catalog>
                 <rewrite>
                     <layer_filter_attribute>AD_Tweaks_Catalog_Block_Layer_Filter_Attribute</layer_filter_attribute>
                     <layer_filter_price>AD_Tweaks_Catalog_Block_Layer_Filter_Price</layer_filter_price>
                </rewrite>
            </catalog>
            <adminhtml>
                <rewrite>
                    <sales_order_grid>AD_Tweaks_Adminhtml_Block_Sales_Order_Grid</sales_order_grid>
                    <sales_order_create_form_account>AD_Tweaks_Adminhtml_Block_Sales_Order_Create_Form_Account</sales_order_create_form_account>
                </rewrite>
            </adminhtml>
         </blocks>
     </global>
</config>

My overriding PHP File located on /app/code/local/AD/Tweaks/Adminhtml/Block/Sales/Order/Grid.php:

    <?php
    class AD_Tweaks_Adminhtml_Block_Sales_Order_Grid extends Mage_Adminhtml_Block_Sales_Order_Grid
    {
        public function __construct()
        {
            // ***This function should be executed, but it fails***
            Mage::log('Class ' . get_class($this) . ' is being created');
            parent::__construct();
        }
}

I tried even to put a Mage::log('1111'); statement on top of the overriding class (before the class operator), but it probably doesn't loads my PHP file because there is no 1111 shown in logs.

The error is displayed in the browser is:

Fatal error: Call to a member function setSaveParametersInSession() on a non-object in /var/www/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Container.php on line 66

Was it helpful?

Solution 2

Well, I solved the problem just by changing the files permissions to www-data instead of root.

OTHER TIPS

You Rewrite grid file location is wrong

/app/code/local/AD/Tweaks/Adminhtml/Block/Sales/Order/Grid.php

should be

/app/code/local/AD/Tweaks/Block/Adminhtml/Sales/Order/Grid.php

Also need to chnage in classs

AD_Tweaks_Block_Adminhtml_Block_Sales_Order_Grid

Also

<sales_order_grid>AD_Tweaks_Adminhtml_Block_Sales_Order_Grid</sales_order_grid>

change

<sales_order_grid>AD_Tweaks_Block_Adminhtml_Sales_Order_Grid</sales_order_grid>
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top