Magento modify admin order items view called by getColumnHtml method

Magento modify admin order items view called by getColumnHtml method

September 9, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento modify admin order items view called by getColumnHtml method

Customizing Magento Admin Order Item Display

Understanding the Default Behavior

In Magento, the admin order item view is primarily defined by two components: the main items template (items.phtml) that structures the table rows, and the renderer templates (like default.phtml) that handle the individual column data.

The default template uses the getColumnHtml() method to generate HTML for each order item column. The code you found in line 68 of the default renderer is an example:

<?php echo $this->getColumnHtml($_item, 'name') ?>

This line fetches and displays the product name using the designated column key (‘name’).

Locating the Relevant Files

You’ve already identified the primary files:

  • Main items template: design/adminhtml/default/default/template/sales/order/view/items.phtml
  • Default renderer template: design/adminhtml/default/default/template/sales/order/view/items/renderer/default.phtml

These are responsible for the overall layout and data rendering, respectively.

Modifying the Product Column

To add additional data to the first column (product), you’ll need to override or extend the main items template. Here’s a step-by-step approach:

1. Create an Override Template

Create a new file at app/design/adminhtml/default/default/template/sales/order/view/items.phtml. This is a copy of the existing file with some modifications.

2. Include the Additional Data

In your override template, you can add custom data before or after the existing product column HTML. For example, to display the product’s SKU:

<?php if ($item->getProduct()): ?>
    <?php $product = $item->getProduct(); ?>
    <div class="clear"></div>
    <strong>SKU:</strong> <?php echo $product->getSku() ?>
    <br />
    <strong>Name:</strong> <?php echo $this->escapeHtml($product->getName()) ?>
<?php endif; ?>

3. Modify the Existing Column

Ensure that you include the original column HTML to maintain the integrity of the table layout:

<td class="cell-actions">
    <div class="actions">
        <?php echo $this->getColumnHtml($_item, 'name') ?>
        <?php echo $this->getColumnHtml($_item, 'product_type') ?>
    </div>
</td>

4. Save and Refresh the Cache

Save your changes and make sure to refresh the Magento admin cache.

Extending the Default Renderer (Advanced)

If you need more fine-grained control over the column data rendering, consider creating a custom renderer by extending Mage_Adminhtml_Block_Sales_Order_View_Renderer_Default. This would allow you to override the specific HTML generation logic for each item.

However, this approach requires a deeper understanding of the Magento block system and is generally more complex than simply overriding templates. It’s recommended for cases where the template modifications aren’t sufficient.

For a comprehensive guide on extending Magento blocks, I recommend checking out our blog post Extending and Overriding Blocks in Magento at Laravel Company.

Conclusion

To summarize:

  1. Identify the relevant templates (items.phtml and default.phtml) for your specific Magento version.
  2. Create an override of the main items template (app/design/adminhtml/default/default/template/sales/order/view/items.phtml).
  3. Add or modify the HTML within the override template to include your additional data.
  4. Maintain the original column structure to preserve table layout consistency.

Remember, Magento 1.x customizations are increasingly complex due to the platform’s age and community support decline. It’s highly recommended to consider migrating your store to Magento 2 for better security, performance, and long-term maintainability. You can find more information on our blog: Why and How to Migrate to Magento 2.

Happy customizing! If you have any further questions or need assistance with a specific implementation, feel free to reach out.

Catalog Database Themes Admin

Our network