what's the event name when you create a new invoice in magento?

what's the event name when you create a new invoice in magento?

July 25, 2026 · Illustrated author avatarBy Stefan Bogdanescu
what's the event name when you create a new invoice in magento?

Magento Invoice Event Names: A Comprehensive Guide

In Magento, when you create an invoice through the admin panel’s sales order section, certain events are triggered that can be observed for further processing or custom requirements. However, finding the correct event name for specific actions can sometimes prove challenging.

Identifying the Correct Invoice Event Name

When you register a new invoice, Magento triggers several events throughout the process. Some of the most common misconceptions involve the use of sales_order_invoice_register and sales_order_invoice_pay. Let’s clarify their roles:

  • sales_order_invoice_register: This event is triggered right after an invoice has been saved but before it is sent to the customer or any additional processing occurs. It does not correspond directly to the act of creating a new invoice.

  • sales_order_invoice_pay: Although this event suggests payment-related actions, it is actually triggered when an invoice is paid off completely through the admin panel or upon successful payment for online orders.

The Correct Event Name: Sales Order Invoice Save After

The event you’re looking for is sales_order_invoice_save_after. This event occurs after an invoice has been successfully saved to the database. It provides a perfect opportunity to execute any necessary post-save actions, such as sending notifications or updating inventory levels.

Here’s how you can create an observer to listen for this event:

  1. Create your observer class: In your custom module, create a file named SalesOrderInvoiceSaveAfterObserver.php with the following content:
<?php

namespace Vendor\ModuleName\Model\Observer;

use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\Event\Observer as EventObserver;
use Psr\Log\LoggerInterface;

class SalesOrderInvoiceSaveAfterObserver implements ObserverInterface
{
    protected $logger;

    public function __construct(LoggerInterface $logger)
    {
        $this->logger = $logger;
    }

    public function execute(EventObserver $observer)
    {
        $invoice = $observer->getEvent()->getObject();

        // Perform your custom logic here using the $invoice object
        $this->logger->info('Invoice saved successfully: ' . $invoice->getIncrementId());
    }
}
  1. Register your observer: In your module’s etc/frontend/events.xml file, add the following configuration:
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="sales_order_invoice_save_after">
        <observer instance="Vendor\ModuleName\Model\Observer\SalesOrderInvoiceSaveAfterObserver" />
    </event>
</config>

Best Practices and Further Reading

  • Use the correct namespace: Ensure you use Magento’s official event namespaces. You can find a list of available events in the Magento Event Reference.

  • Observe the object correctly: The getObject() method in your observer should contain the invoice object you need to process.

For more advanced scenarios and customizations, consider exploring Magento’s Event-Dispatcher system or learning about custom events.

Conclusion

In summary, the correct event name for observing invoice creation in Magento is sales_order_invoice_save_after. This event provides a reliable way to perform post-save actions on invoices created through the admin panel.

Don’t forget to explore other invoicing-related events and observe objects available in your observer methods. By understanding the Magento event system, you can build powerful extensions that enhance the core functionality of the platform.

Remember, if you need expert guidance or assistance with complex Magento customizations, don’t hesitate to reach out to our team at Laravel Company. We provide professional services for all your e-commerce development needs.

Database Extensions Admin Orders

Our network