GreenTree ⇄ Magento Integration
This is the technical reference for the Ecommistry_GreenTree Magento module
(app/code/Ecommistry/GreenTree/), which synchronises data between RLB's Magento
(Adobe Commerce) storefront and the MYOB Greentree ERP.
The documentation is authored directly from the module source. Every claim links back
to a concrete file or class under app/code/Ecommistry/GreenTree/.
What the integration does
The module runs two independent, one-directional pipelines that together give a bidirectional sync:
| Direction | Entities | Trigger | Queue table |
|---|---|---|---|
| Greentree → Magento | Products, images, product links, customers, prices / custom products, stock, order status back-sync | Console commands + hourly cron | greentree_to_mage_queue |
| Magento → Greentree | Sales orders (B2B & B2C) | Order events + console command | mage_to_greentree_queue |
Each pipeline is a two-phase, queue-backed flow:
- Fetch / capture and enqueue — pull records from the source system (or capture a Magento event) and write a JSON message row into the relevant queue table.
- Process / apply — read queued rows in batches and apply them to the destination system, tracking attempts and status per row.
Module facts
- Module name:
Ecommistry_GreenTree(registration.php,etc/module.xml). - Module dependencies (
sequence):Magento_Catalog,Magento_Customer,Magento_Company(etc/module.xml). - File count: 112 PHP/XML files.
- HTTP client:
Model/ApiClient.php— talks to the Greentree REST endpoint through theEcommistry\GreenTreeLibrarySDK. - Command dispatch: a lightweight Command/Handler pattern driven by
Model/Command/CommandBus.php.
Documentation map
| Page | Contents |
|---|---|
| Architecture | Module layout, bidirectional-sync model, Command/Handler + CommandBus pattern. |
| Greentree → Magento | Products, images, links, customers, prices/custom products, stock; the console commands and cron that drive them. |
| Magento → Greentree | Order push; observers on checkout_submit_all_after (B2B) and sales_order_invoice_pay (B2C). |
| API client | Greentree endpoints, auth, request/response shapes. |
| Admin configuration | system.xml fields and the config readers that consume them. |
| Data model | Both queue tables, the log table, the order-dictionary table, statuses and retry handling. |
| Console commands | The ~14 CLI commands, their arguments, and cron cadence. |
| Field & entity mapping | Magento ↔ Greentree attribute and field mapping tables. |
Scope
This is the technical reference only. Non-technical guides are tracked separately (RLB-28), and the Docusaurus site scaffolding — which renders these pages — is provided by RLB-29.