How to add custom block after items block into order view page in magento

In order view page, add a custom block after any type of block. Here I show you, how you can create a block after items block. You can visit my previous post overwrite sales order view. 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

<config>
    <modules>
        <Exercise_CustomSales>
            <active>true</active>
            <codePool>local</codePool>
        </Exercise_CustomSales>
    </modules>
</config>

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

<config>
    <modules>
        <Exercise_CustomSales>
            <version>1.7.0.2</version>
        </Exercise_CustomSales>
    </modules>
    <adminhtml>
        <layout>
            <updates>
                <customsales>
                    <file>exercise_customsales.xml</file>
                </customsales>
            </updates>
        </layout>
    </adminhtml>
    <global>
        <blocks>
            <customsales>
                <class>Exercise_CustomSales_Block</class>
            </customsales>
        </blocks>
    </global>
</config>

Step 3: Create a block app/code/local/Exercise/CustomSales/Block/Sales/Order/View/Custom.php

class Exercise_CustomSales_Block_Sales_Order_View_Custom extends Mage_Core_Block_Template
{
    
}

Step 4: Create a layout config file app/design/adminhtml/default/default/layout/exercise_customsales.xml

<layout version="0.1.0">
    <adminhtml_sales_order_view>
        <reference name="order_items">
            <action method="setTemplate"><template>customsales/sales/order/view/items.phtml</template></action>
            <block type="customsales/sales_order_view_custom" name="customsales_sales_order_view_custom" template="customsales/sales/order/view/custom.phtml"/>
        </reference>
    </adminhtml_sales_order_view>
</layout>

Step 4: Copy sales/order/view/items.phtml into customsales/sales/order/view/items.phtml
Open this file and add one line code, look like,

<div class="grid np">
......
......
</div>
<br />
<?php echo $this->getChildHtml('customsales_sales_order_view_custom');?>

Step 5: Create a new file customsales/sales/order/view/custom.phtml, you can add your custom content. Clear cache and go to order view page.

Enjoy magento code!

2 thoughts on “How to add custom block after items block into order view page in magento

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s