How emizentech/magento2-customordernumber works
This Magento 2 module customizes order and invoice increment IDs. Magento’s order and invoice lifecycle events invoke separate observers; each reads store settings, advances its own persisted counter, and saves a prefixed/suffixed ID to the sales entity. The schema defines the two counter tables. Event registration and admin configuration exist in the tree, but their contents were not sampled, so those wiring details are not asserted.
Main entry points: ChangeOrderId.php Order numbering · ChangeInvoiceId.php Invoice numbering · Orderid.php Order counter model · Invoiceid.php Invoice counter model
Components 15
Number generation
- Order numbering
Observer/ChangeOrderId.php - Invoice numbering
Observer/ChangeInvoiceId.php
Counter persistence
- Order counter model
Model/Orderid.php - Invoice counter model
Model/Invoiceid.php - Order counter resource
Model/Resource/Orderid.php - Invoice counter resource
Model/Resource/Invoiceid.php - Order counter collection
Model/Resource/orderid/Collection.php - Invoice counter collection
Model/Resource/invoiceid/Collection.php
Module setup
- Counter schema
Setup/InstallSchema.php - Event configuration
etc/events.xml - Admin settings
etc/adminhtml/system.xml - Default settings
etc/config.xml
Other components
- Magento Sales
- Store settings
- Counter tables
Connections 17
- Magento Sales → Order numbering: invokes order observer
- Magento Sales → Invoice numbering: invokes invoice observer
- Order numbering → Store settings: reads settings
Observer/ChangeOrderId.php - Invoice numbering → Store settings: reads settings
Observer/ChangeInvoiceId.php - Order numbering → Order counter model: updates counter
Observer/ChangeOrderId.php - Invoice numbering → Invoice counter model: updates counter
Observer/ChangeInvoiceId.php - Order numbering → Magento Sales: saves order ID
Observer/ChangeOrderId.php - Invoice numbering → Magento Sales: saves invoice ID
Observer/ChangeInvoiceId.php - Order counter model → Order counter resource: uses resource
Model/Orderid.php - Invoice counter model → Invoice counter resource: uses resource
Model/Invoiceid.php - Order counter collection → Order counter model: initializes collection
Model/Resource/orderid/Collection.php - Order counter collection → Order counter resource: initializes collection
Model/Resource/orderid/Collection.php - Invoice counter collection → Invoice counter model: initializes collection
Model/Resource/invoiceid/Collection.php - Invoice counter collection → Invoice counter resource: initializes collection
Model/Resource/invoiceid/Collection.php - Counter schema → Counter tables: creates tables
Setup/InstallSchema.php - Order counter resource → Counter tables: accesses order table
Model/Resource/Orderid.php - Invoice counter resource → Counter tables: accesses invoice table
Model/Resource/Invoiceid.php