Magento - Add comments to invoice from back admin

Magento - Add comments to invoice from back admin

August 16, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento - Add comments to invoice from back admin

Adding Comments to Magento Orders in Admin and Printing on Invoices

Hello developers! Today, we’re going to tackle a common question: how can you add comments to orders in the Magento admin area, and have those comments print out on invoices? Let’s dive into this step-by-step.

Understanding the Magento Order Management System

Before we get started, it’s essential to understand that the Magento order management system is designed with flexibility and customization in mind. This means you can extend its functionality using various methods like custom attributes, observers, or even third-party extensions.

The out-of-the-box features already allow you to add notes to orders from the admin area. However, these notes are not included on printed invoices by default. To achieve this, we’ll need to modify some core files and create a new observer.

Adding Comments in the Magento Admin Area

To start, navigate to your order management area in the Magento back-end. For each order, you can already see a ‘Notes’ section under the ‘Comments History’ tab.

This is where you can add internal comments about an order. These comments are visible only to admin users and do not appear on customer-facing documents like invoices or shipments by default.

Creating a Custom Comment Attribute

While the existing ‘Notes’ field serves our purpose, it would be better to create a separate attribute for invoice comments to keep things organized. Here’s how you can do it:

  1. In your Magento root directory, navigate to app/code/core/Mage/Catalog/Model/Resource/Eav/Attribute.php.

  2. Around line 837, find the $default_groups array and add this entry:

    'Sales' => array(
        array(
            'label' => Mage::helper('sales')->__('Invoice Comments'),
            'sort_order' => 10,
            'fields' => array(
                array(
                    'label' => Mage::helper('sales')->__('Use system value'),
                    'input' => 'select',
                    'type' => 'int',
                    'source' => 'eav/entity_attribute_source_boolean'
                ),
                array(
                    'label' => Mage::helper('sales')->__('Is required'),
                    'input' => 'select',
                    'type' => 'int',
                    'source' => 'eav/entity_attribute_source_boolean'
                )
            )
        )
    ),
    
  3. Save the file.

This code extends the Magento admin area to include a new attribute group for sales data, specifically for invoice comments. The sort order ensures it appears near the top of the ‘Sales’ tab in your attribute management interface.

Creating an Observer to Print Comments on Invoices

Now let’s create an observer to print the custom comment on invoices:

  1. In your Magento root directory, navigate to app/code/local/Magento/PrintComments/Model/Observer.php.

  2. Add this code:

    <?php
    class Magento_PrintComments_Model_Observer
    {
        public function addInvoiceComment($observer)
        {
            $event = $observer->getEvent();
            $invoice = $event->getInvoice();
    
            // Retrieve the custom comment attribute value
            $commentAttributeId = Mage::helper('catalogattribute')->getAttribute(Mage_Catalog_Model_Product::ENTITY, 'invoice_comments');
            $customComment = $invoice->getData($commentAttributeId);
    
            if (!empty($customComment)) {
                Mage::log('Invoice Comment: ' . $customComment);
                // Add the comment to the invoice PDF
                // You will need to modify Magento's PDF generation classes (app/code/core/Mage/Sales/Model/Order/Pdf/Items.php and others) to include this comment
            }
        }
    }
    

Note: The line // Add the comment to the invoice PDF is a placeholder for the actual code that needs to be added in the appropriate PDF generation files. This requires modifying Magento’s core classes, which should be done with extreme caution.

Conclusion

Adding comments to invoices in Magento involves extending the core functionality by creating custom attributes and observers. While this provides a solution, it’s important to note the risks of directly modifying core files.

If you’re not comfortable working at this level, consider using an extension from a trusted source or consulting with a Magento developer. Remember that any changes to core files can be overwritten during updates, so always backup your work before proceeding.

I hope this guide helps you add invoice comments in the Magento admin area and print them on invoices. If you’re looking for professional assistance with your Magento development needs, feel free to reach out to Laravel Company. We specialize in custom Magento solutions tailored to your business requirements.

Extensions Admin Orders Customers

Our network