# Esun_LingxingErp Lingxing warehouse integration uses these official endpoints: - Warehouse list: `POST /erp/sc/data/local_inventory/warehouse` - https://apidoc.lingxing.com/#/docs/Warehouse/WarehouseLists - Warehouse inventory details: `POST /erp/sc/routing/data/local_inventory/inventoryDetails` - https://apidoc.lingxing.com/#/docs/Warehouse/InventoryDetails `Sync Warehouses` uses the active platform `10009` records already cached under **Lingxing ERP > Stores** to select only the required Lingxing warehouses: - Store `Magento` -> warehouse `US Stock` - Store `Magento-UK` -> warehouse `UK Stock` - Store `Magento-EU` -> warehouse `EU Stock` - Store `Magento-AU` -> warehouse `AU Stock` No other Lingxing warehouses are persisted or turned into Magento Sources. Each selected warehouse is represented by a Source with the stable code `lingxing_{wid}`. Assign those Sources to Magento Stocks before running `Sync Inventory`. Inventory quantity is sourced from Lingxing `product_valid_num`. Magento-to-Lingxing order export and Lingxing-to-Magento shipment import. ## Scope - Enqueues Magento orders when they enter a configured status (default: `processing`). - Creates Lingxing custom-platform orders using Magento `increment_id` as the idempotency key. - Queues `/basicOpen/wmsOrder/cancel` when a synchronized Magento order is canceled, records whether the cancellation came from the customer, a scheduled task, an administrator, or another system process, and retries failed cancellation submissions without blocking Magento cancellation. - Pulls completed Lingxing sales outbound orders every three minutes. - Creates one Magento shipment per Lingxing `wo_number`. - Creates package-level shipments only when Lingxing supplies package-level item quantities; otherwise attaches all package tracking numbers to one shipment. - Stores current order/shipment synchronization status and a sanitized attempt history. - Persists Lingxing stores locally and refreshes them only when an administrator requests it. - Pulls Lingxing PairListV2 mappings once per day for each configured Website and writes the returned local `sku` to the Website-scoped product `erp_sku` attribute. - Sends each Website's Magento SKUs as `msku` together with its configured `platform_codes` and `store_ids` when querying PairListV2. - Provides store, order, shipment and log grids plus retry actions under **Esun > Lingxing ERP**. - Keeps full sanitized payloads for failed/retrying logs for 90 days. Successful/ignored logs contain compact hashes and counts only and are retained for 14 days; both windows are configurable. The log grid defaults to failed/retrying rows until a status filter is selected. - Provides detail pages for order, shipment and attempt-log records with sanitized request and response payloads. The `erp_sku` attribute is not exposed to storefront search. ERP SKU uniqueness is enforced within each Magento Website, while the same ERP SKU may be used by different Websites. ## Configuration Configure under **Stores > Configuration > Esun > Lingxing ERP**: - API Base URL - App ID - App Secret (encrypted and marked sensitive) - a Lingxing store mapping selected separately at each Magento Website scope; options are read from the local store table - optional warehouse and logistics type (both must be supplied together) - Magento order statuses eligible for export Do not put credentials in source code or logs. Production must whitelist the Magento server's public IP in Lingxing. After saving the API credentials, open **Esun > Lingxing ERP > Stores** and click **Sync Stores** once. Repeat the manual synchronization only when the Lingxing store list changes. The system configuration page never calls Lingxing directly. Store API failures are recorded in **Synchronization Logs**. Product ERP SKUs synchronize daily at 02:17 in the Magento cron timezone. Administrators can also run the synchronization immediately from **Esun > Lingxing ERP > Stores**. The Website-scoped product `erp_sku` attribute is the sole source of truth; no separate mapping table is maintained. PairListV2 request and response payloads are recorded under the `sku_pair_lookup` operation. ## Deployment ```bash php bin/magento module:enable Esun_LingxingErp php bin/magento setup:upgrade php bin/magento setup:di:compile php bin/magento cache:flush ``` Magento cron must be installed and running. API synchronization remains disabled until the configuration flag is enabled.