How to add a block inside order sales view in magento

How to add a block inside order sales view in magento

September 3, 2026 · Illustrated author avatarBy Stefan Bogdanescu
How to add a block inside order sales view in magento

Adding a custom block inside the Sales Order View in Magento involves a multi-step process that requires modifying layout XML files and creating your own block and template files. Here’s a step-by-step guide on how to achieve this without editing any core files:

Step 1: Create Your Custom Block

First, you need to create your custom block file inside your module. Let’s assume your module is called “Your_Company_Magento”.

Navigate to app/code/local/Your/Company/Magento/Block/Adminhtml/Sales/Order/View/. Inside this folder, create a new PHP file named Reservationbooking.php.

The contents of the file should look like this:

<?php

class Your_Company_Magento_Block_Adminhtml_Sales_Order_View_Reservationbooking extends Mage_Core_Block_Template {
}

This block is extending from Mage_Core_Block_Template, which allows you to use the default template system.

Step 2: Create Your Custom Template

Next, create a new template file for your custom block. In the same folder as your Reservationsbooking.php file (i.e., inside app/code/local/Your/Company/Magento/Block/Adminhtml/Sales/Order/View/), create a new subfolder named reservationbooking.

Inside this new folder, create another folder named template. Inside this final folder, create a PHP file with the name reservationbooking.phtml.

The contents of the reservationbooking.phtml file should be:

<?php

echo "Reservation Booking Data";

?>

This is just a simple example where we’re echoing a string for demonstration purposes. You can replace this with your actual reservation booking data.

Step 3: Add Your Custom Block to the Layout XML

Now, let’s modify the layout XML file to include our new block in the Sales Order View.

Navigate to app/design/adminhtml/default/default/layout/ and locate the sales_order_view.xml file. Open this file for editing.

Find the <reference name="order_tab_info"> section within the <adminhtml_sales_order_view> block. Inside this reference, add the following code:

<block type="yourcompany_magento/adminhtml_sales_order_view_reservationbooking" name="reservationbooking" template="yourcompany_magento/sales/order/view/reservationbooking.phtml"/>

Note: Replace “yourcompany_magento” with your actual module’s prefix. This is the same as the folder structure under app/code/local where you placed your module files.

Step 4: Refresh Your Cache

After making these changes, make sure to clear your Magento cache for the modifications to take effect. You can do this by going to System > Cache Management and doing a “Flush Magmi Cache”.

Conclusion

By following these steps, you should be able to add a custom block with its own template inside the Sales Order View in Magento without having to edit any core files.

Remember, when working with Magento’s layout XML and block system, always ensure that your naming conventions are consistent with your module prefix. Also, it’s best practice to keep your customizations separate from the core files for easier upgrades and maintenance.

For more detailed guides on Magento development, make sure to check out our blog at https://laravelcompany.com. We regularly publish articles on Magento development best practices, tips, and tricks.

Extensions Themes Admin Orders

Our network