Magento Overwrite in Adminhtml failing

442 views Asked by At

So I've tried everything I can think of tfor this order info page and exhausting every search I can think of, so now I need to ask. I'm trying to rewrite the admin>sales order>view order page. I have created the module to overwrite what I thought was the area but it's getting all funky.

config.xml for the module

<config>
<modules>
    <Mage_Salespage>
        <version>0.1.0</version>
    </Mage_Salespage>
</modules>

<global>

    <blocks>

        <adminhtml>
            <rewrite>
                <sales_order_view>Mage_Salespage_Block_Sales_Order_View_Info</sales_order_view>
            </rewrite>
        </adminhtml>

    </blocks>

    <helpers>
        <mage_salespage>
            <class>Mage_Salespage_Helper</class>
        </mage_salespage>
    </helpers>
    <models>
        <mage_salespage>
            <class>Mage_Salespage_Model</class>
        </mage_salespage>
    </models>

</global>

The Info.php for the module

class Mage_Salespage_Block_Sales_Order_View_Info extends Mage_Adminhtml_Block_Sales_Order_View_Info
{
    protected function _construct()
    {
    $this->setTemplate('salespage/sales/order/view/info.phtml');
    }     
}

Issue shown at https://i.stack.imgur.com/QQ2dZ.png since I don't have enough rep yet What am I doing wrong?

2

There are 2 answers

0
Amit Bera On BEST ANSWER

Fluffs McKenzie, There are issue in block type code at config.xml.

You want to rewrite class Mage_Adminhtml_Block_Sales_Order_View_Info

As per as magento it block type is

adminhtml/sales_order_view_info but you was rewrite class admihtml/sales_order_view .

when a block type adminhtml/sales_order_view_info then it class emulate by this process:

  • adminhtml -> Mage_Adminhtml_Block
  • sales_order_view_info -> Sales_Order_View_Info

then final class is Mage_Adminhtml_Block_Sales_Order_View_Info

So you need change at

from

<sales_order_view>Mage_Salespage_Block_Sales_Order_View_Info</sales_order_view>

To

<sales_order_view_info>Mage_Salespage_Block_Sales_Order_View_Info</sales_order_view_info>
0
espradley On

Couple things could be happening here. First, did you make sure you put it in the right folder? If you put it in blocks/Adminhtml/sales/order/view.php, then you need to adjust your class name and xml declaration for it. You can check this quickly by turning on DEV mode in the index.php file.

One other thing that's a bit more common is if there is another module that is overriding this method. Since Magento loads modules in alphabetical order, yours may not get the chance to overwrite the class first. If that's the case, you just need to add a depends clause in your app/etc/modules/module.xml file.

I'd download this extension: http://www.magepsycho.com/easy-template-path-hints.html

It allows you to run template path hints by adding some url params and works in the admin. This will show you whether or not your product view block is using core or if it's using some other extensions code.