How to? Customize backend template (F.e. Sales order information)

Last modified by [m] zentrale on Fri, June 25, 2010 09:35
Source|Old Revisions  

This is an old revision of the document!


This how to exlains by a short example how developers can customize backend templates by overloading a block.

Scenario: We have collected additional data during the ceckout prozess and saved them into the order. Now we want to display these datas within the order overview in backend.

The block displaying order data is located in app/code/core/Mage/Adminhtml/Sales/Order/View/Info.php. If we take a look at this class we see following code setting the template:

<?php protected function _construct() { $this→setTemplate(’sales/order/view/info.phtml’); } ?>

Easiest way to chage template would be to change code of info.phtml. But we should protect our code from beeing overwritten by magento updates. The solution? Overloading the block.

1st Step: We create our own extension 2nd Step We create our own block. For example: Mymodule/Block/Sales/Order/View/Info.php

class Mage_Mymodule_Block_Sales_Order_View_Info extends Mage_Adminhtml_Block_Sales_Order_View_Info { protected function _construct() { $this→setTemplate(’mymodule/sales/order/view/info.phtml’); } }

3rd Step We create our own .phtml file in design/adminhtml/default/default/template/mymodule/sales/order/view/info.phtml and customize it.

4th Step Overload Mage_Adminhtml_Block_Sales_Order_View_Info with own block out of own module. We add to config.xml within <default> node:

<blocks> <adminhtml> <rewrite> <sales_order_view_info>Mage_Mymodule_Block_Sales_Order_View_Info</sales_order_view_info> </rewrite> </adminhtml> </blocks>




 

Magento 2 GitHub Repository

Magento Job Board - Some sort of tag line goes here

Latest Posts| View all Jobs