How to overwrite sales view order phtml file in magento

If you need to customize sales view order or customize your view order phtml page for admin , then you need to overwrite this phtml file. You don’t should customize the core phtml file. You should customize your own file. So lets start.
Suppose namespace is “Exercise” and module name is “CustomSales”

Step 1 : Create a module config file into app/etc/modules/Exercise_CustomSales.xml


Step 2: Create a config file under app/code/local/Exercise/CustomSales/etc/config.xml


Step 3 : Create a php file which is overwrite the actual order info file, app/code/local/Exercise/CustomSales/Block/Sales/Order/View/Info.php

class Exercise_CustomSales_Block_Sales_Order_View_Info extends Mage_Adminhtml_Block_Sales_Order_View_Info

Step 4 : you should create a xml file inside layout folder(Possible path: app/design/adminhtml/default/default/layout).

For example : exercise_customsales.xml

Your code should be:

<layout version="0.1.0">
        <reference name="order_info">
            <action method="setTemplate"><template>customsales/sales/order/view/info.phtml</template></action>

Step 5 : Then you need to create a file inside template folder (Possible path: app/design/adminhtml/default/default/template), customsales/sales/order/view/info.phtml.

copy all content from sales/order/view/info.phtml into customsales/sales/order/view/info.phtml, and you can change here and related block file is now app/code/local/Exercise/CustomSales/Block/Sales/Order/View/Info.php

Change those file as you required.

Step 6: Clear the cache


13 thoughts on “How to overwrite sales view order phtml file in magento

  1. some syntax highlighting and code formating would be a great “update” for this article. But still a nice article! Thanks

  2. Hello Sohel,
    It works well.
    But can you tell me how to add it on top of all the blocks like, I wanna add my custom block above the billing and shipping address blocks.

    1. You can place a custom block any where in side ‘info.phtml’. add a block something like
      <block type=”customsales/sales_order_view_custom” name=”customsales_sales_order_view_custom” template=”customsales/sales/order/view/custom.phtml”/>
      and call this block inside phtml -> echo $this->getChildHtml(‘customsales_sales_order_view_custom’);

      here is an example ->

  3. I want to override sales order grid and filter by order id, I want display only few order ids not all, How can I do this ?

  4. Hi there,

    i followed the above mentioned steps, after applying all, i am getting en error now, here it is:

    class Kulvinder_Singh_Block_Sales_Order_View_Info extends Mage_Adminhtml_Block_Sales_Order_View_Info { }
    Fatal error: Class ‘Kulvinder_Singh_Block_Sales_Order_View_Info’ not found in /home/xxx/public_html/ on line 491

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.