cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 1 - Override block in module

Highlighted

Magento 1 - Override block in module

Is their any way we can override this block

app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Items/Grid.php

into module ?

Config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <vendor_module>
            <version>
                0.1.0
            </version>
        </vendor_module>
    </modules>
    <global>
        <blocks>
            <adminhtml>
                <rewrite>
                    <sales_order_create_items_grid>
                        Vendor_Module_Adminhtml_Block_Sales_Order_Create_Items_Grid
                    </sales_order_create_items_grid>
                </rewrite>
            </adminhtml>
        </blocks>
    </global>
</config>

Vendor/Module/Block/Adminhtml/Sales/Order/Create/Items/Grid.php

<?php

class Vendor_Moduley_Adminhtml_Block_Sales_Order_Create_Items_Grid extends Mage_Adminhtml_Block_Sales_Order_Create_Items_Grid
{
    /**
     * Flag to check can items be move to customer storage
     *
     * @var bool
     */
    protected $_moveToCustomerStorage = true;

    /**
     * Class constructor
     */
    public function __construct()
    {
        parent::__construct();
        $this->setId('sales_order_create_search_grid');
    }

    /**
     * Returns the items
     *
     * @return array
     */
    public function getItems()
    {
        echo'check'; exit;
    }
}

This code is not working, any thoughts where is the issue ? 

4 REPLIES 4
Highlighted

Re: Magento 1 - Override block in module

Hi @hamendrasub7ef ,

 

Can you check below link to check your block override code

https://magento.stackexchange.com/questions/133186/how-do-i-override-rewrite-a-block-class-in-magent...

one suggestion you are using global + adminhtml both tag in config.xml

use one and check the changes.

 

Hope this helps you!

Problem Solved! Click Kudos & Accept as Solution!

 

Highlighted

Re: Magento 1 - Override block in module

Sir, i am getting this error - Mage_Core_Exception: Invalid block type:
Vendor_Mudule_Block_Sales_Order_Create_Items_Grid

Highlighted

Re: Magento 1 - Override block in module

Hi @hamendrasub7ef ,

 

Replace your XML code with below

<?xml version="1.0"?>
<config>
    <modules>
        <vendor_module>
            <version>                0.1.0
            </version>
        </vendor_module>
    </modules>
    <adminhtml>
        <blocks>
                <rewrite>
                    <sales_order_create_items_grid>                        Vendor_Module_Adminhtml_Block_Sales_Order_Create_Items_Grid
                    </sales_order_create_items_grid>
                </rewrite>
        </blocks>
    </adminhtml>
</config>


Hope this helps you!

Problem Solved! Click Kudos & Accept as Solution! 

Highlighted

Re: Magento 1 - Override block in module

have you done something to vanish it?