The Home for Magento 2 Excellence

Automated build tests for Magento 2 modules. Explore. Evaluate. Elevate. #magento2

1059 Modules
741 Ready
317 Need Help
Vendors 🏆 Leaderboard
Actively Maintained v1.2.0 GPL-3.0-only

Order Event Dispatcher for Magento 2

butterfly-team/magento-order-event-dispatcher 66

Triggers order-related Magento events (sales_order_place_after, checkout_submit_all_after, sales_order_save_after) for an existing order via a secret-key-secured URL, useful for processing orders created directly in the database.

292
Downloads
Below average
2
GitHub Stars
Below average
8d ago
Last Release
0
Open Issues
Build Passing
Ready to install

Build Tests

Composer Install
DI Compile
Templates

Code Quality

CS Coding Standard
24 errors , 26 warnings
L5 PHPStan

Release Discipline

Follows SemVer · 100% What is this?

Release history audited up to v1.2.0

Tested on Magento 2.4.9

Recent Test History

Each release is tested against the latest Magento version at that time.

v1.2.0 on Magento 2.4.9
Nov 23, 2026
v1.1.1 on Magento 2.4.9
Jun 7, 2026
v1.0.9 on Magento 2.4.9
Jun 1, 2026

Share This Module's Status

Order Event Dispatcher for Magento 2 Magento compatibility status badge

README

Loaded from GitHub

Magento 2 Order Event Dispatcher Module

This Magento 2 module allows you to trigger order-related events for an existing order via a URL. This is useful when you manually create orders in the Magento database and want to trigger events for processing workflows such as inventory updates, email notifications, and more.

Features

  • Trigger Magento 2 order events for an existing order ID via a URL.
  • Supports events: sales_order_place_after, checkout_submit_all_after, sales_order_save_after.
  • Secured with a secret key to ensure only authorized requests can trigger the events.

Install/update using Composer

Composer is a dependency management tool for PHP. It allows you to declare the libraries your project depends on, and it will manage the installation or update of these libraries.

Prerequisites

Make sure Composer is properly installed in your environment. Learn more at https://getcomposer.org.

Install/Update

  1. In your Magento root directory, run the following command to add the module via Composer:
    composer require butterfly-team/magento-order-event-dispatcher
    
  2. Then, update your Magento setup:
    bin/magento setup:upgrade
    bin/magento setup:di:compile
    bin/magento cache:flush
    

Uninstalling the Module

To remove the module installed via Composer, use these commands:

  1. In your Magento root directory:
    composer remove butterfly-team/magento-order-event-dispatcher
    

Securing the Endpoint with a Secret Key

To secure the endpoint, configure a secret key in Magento’s core_config_data table:

  1. Add the secret key in the Magento admin:

    • Go to Stores > Configuration > Advanced > Developer.
    • Set a value under the configuration path: butterfly/order_event_dispatcher/secret_key.

    Alternatively, add the key directly to the database:

    INSERT INTO core_config_data (scope, scope_id, path, value)
    VALUES ('default', 0, 'butterfly/order_event_dispatcher/secret_key', 'your_secret_key_here');
    
  2. Replace your_secret_key_here with a secure, unique key.

Usage

To trigger order events for an existing order, use the following URL structure in your browser or API client:

http://your-magento-site.com/order_event_dispatcher/index/dispatch?order_id=<ORDER_ID>&secret=your_secret_key_here

Replace <ORDER_ID> with the actual order ID in the Magento database and your_secret_key_here with your configured secret key. The module will respond with a JSON message indicating the success or failure of the event dispatch.

Example

For an order with ID 1, access:

http://your-magento-site.com/order_event_dispatcher/index/dispatch?order_id=1&secret=your_secret_key_here

Events Triggered

  • sales_order_place_after: Dispatched after an order is placed.
  • checkout_submit_all_after: Dispatched after checkout submission.
  • sales_order_save_after: Dispatched after an order is saved.

You can customize which events are triggered in the Dispatch.php controller file.

Idempotency

Each order is dispatched once. The module adds sales_order.butterfly_dispatched_at; a request sets it atomically before firing the events, and a repeated request for the same order returns success: true with already_dispatched: true without firing events or sending the order email again. If dispatching throws, the flag is cleared so the caller can retry.

setup:upgrade backfills the flag with created_at for orders from the last 30 days, in batches of 1000 ids, so a retry job does not dispatch them again. Butterfly only retries orders from the last 24 hours; older orders keep a NULL flag.

Troubleshooting

  • Ensure the module is enabled:
    php bin/magento module:status Butterfly_OrderEventDispatcher
    
  • Check Magento logs (var/log/system.log and var/log/exception.log) for any errors.

License

This module is open-source and free to use. Feel free to modify it to suit your needs.

Tests

composer install
composer test

The unit tests run without a Magento install; Test/Unit/stubs.php stands in for the Magento classes the controller touches.

This content is fetched directly from the module's GitHub repository. We are not the authors of this content and take no responsibility for its accuracy, completeness, or any consequences arising from its use.