Magento add block to sales order create

Magento add block to sales order create

October 2, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento add block to sales order create

Adding a Custom Block to Magento Admin Sales Order Create Screen

When working with Magento admin sales order creation, you might need to add custom blocks for specific functionalities like adding insurance options or additional fees. In your case, you’re trying to insert a block called fee.insurance under the shipping method section using the layout XML file.

Your current setup looks correct in terms of structure:

<adminhtml_sales_order_create_index>
    <reference name="head">
        <action method="addItem"><type>skin_js</type><name>js/fee/fee.js</name></action>
    </reference>
    <reference name="data">
             <block type="fee/adminhtml_insuranceselector" after="shipping_method" name="fee.insurance" template="fee/sales/order/insuranceselector.phtml" />
    </reference>
</adminhtml_sales_order_create_index>

<adminhtml_sales_order_create_load_block_data>
    <reference name="data">
             <block type="fee/adminhtml_insuranceselector" after="shipping_method" name="fee.insurance" template="fee/sales/order/insuranceselector.phtml" />
    </reference>
</adminhtml_sales_order_create_load_block_data>

However, you’re facing an issue where the block isn’t appearing under the “data” reference and only appears if moved to the “left” area. This suggests that there might be a conflict in the existing layout setup or missing dependencies.

Understanding Magento Layout Structure

In Magento 2, the admin sales order create page uses multiple layout handles:

  • adminhtml_sales_order_create_index: The main handle for the index action.
  • adminhtml_sales_order_create_load_block_data: Used to load block data during the creation process.

The “data” reference is a container for various blocks and data necessary for the order creation process. It might be already occupied by core Magento blocks, preventing your custom block from appearing.

To resolve this issue, I would suggest creating a new <block> element under a different reference name that suits your requirements better. The “content” area doesn’t have a direct template file because it’s used to output content generated by other blocks or controller actions.

Here’s an updated version of your layout XML:

<adminhtml_sales_order_create_index>
    <reference name="head">
        <action method="addItem"><type>skin_js</type><name>js/fee/fee.js</name></action>
    </reference>
    <reference name="content">
             <block type="fee/adminhtml_insuranceselector" after="shipping_method" name="fee.insurance" template="fee/sales/order/insuranceselector.phtml" />
    </reference>
</adminhtml_sales_order_create_index>

<adminhtml_sales_order_create_load_block_data>
    <reference name="content">
             <block type="fee/adminhtml_insuranceselector" after="shipping_method" name="fee.insurance" template="fee/sales/order/insuranceselector.phtml" />
    </reference>
</adminhtml_sales_order_create_load_block_data>

In this example, I’ve moved the block to the “content” reference area instead of “data”. This should allow your custom block to appear under the shipping method section without any conflicts.

Conclusion

Adding a custom block to Magento admin sales order creation involves understanding the layout structure and references. In most cases, moving the block to an appropriate reference name like “content” or creating a new one solves the issue of blocks not appearing in the desired location.

Remember that whenever you modify core files directly, it can lead to issues during updates. It’s always recommended to use configuration files or create your own modules for customizations. LaravelCompany provides comprehensive guides on Magento development best practices and module creation.

If you’re still facing issues, please review the code examples provided above and ensure you have properly configured the block type and template file paths in your custom module.

Magento 2 Themes Admin Orders

Our network