NFusion Pricing Sync
The NFusion Pricing Sync system is the core function of the Middleware Platform. It periodically fetches live spot prices and markups from the nFusion Solutions precious-metals API and pushes them to the Retail WooCommerce site, the Dealers WooCommerce site, and/or Algolia search indices.
How It Works
nFusion API (per-tenant base URL)
│
│ GET /service/Price/PricesByChannel
▼
NFusionService::getPrices()
│ Returns array of { sku, ask, bid, wholesale_ask, wholesale_bid, tiers, ... }
▼
PriceSyncService::syncPricesForTenant()
│
├──▶ AlgoliaSyncTargetProvider::sync() → updates Algolia index records
├──▶ WooCommerceSyncTargetProvider::sync() → writes wp_postmeta rows directly
└──▶ HttpSyncTargetProvider::sync() → POST/PUT/PATCH to a custom endpoint
Multi-Tenant Architecture
The system supports multiple tenants — each tenant corresponds to one nFusion account. Common tenants:
| Tenant | Description |
|---|---|
| Retail | Scottsdale Mint retail WooCommerce store |
| Dealers | Wholesale dealer WooCommerce store |
Each tenant has:
- Its own nFusion API alias (
{alias}.nfusioncatalog.com) - Its own API token (stored as an env-var name in the database)
- Its own sales channel and currency
- One or more Sync Targets (described below)
Sync Targets
Each tenant can have multiple sync targets. A sync target defines:
- Type —
WooCommerce,Algolia, orHTTP - Settings — provider-specific configuration (DB connection, index name, endpoint URL, etc.)
- Active flag — disabled targets are skipped
- Dry-Run flag — runs the sync logic without writing to the destination
Schedule
The sync runs on a cron-style schedule (default: every 5 minutes) via the Laravel scheduler. Each run:
- Loads all active tenants (
NFusionTenant::active()) - For each tenant, dispatches
NFusionSyncTenantPricesJobonto thenfusionqueue - Each job fetches prices once and iterates all active sync targets
Sync Logs
Every sync run creates an NFusionSyncLog record with:
- Start/end timestamps
- Status (
running→success/partial/error) - Attempted and processed SKU counts
- Detailed per-SKU items in
NFusionSyncLogItem
Logs are viewable in the Filament admin under nFusion → Sync Logs.
Key Files
| File | Description |
|---|---|
app/Services/NFusionService.php | API client — fetches prices from nFusion |
app/Services/PriceSyncService.php | Orchestrator — iterates tenants and targets |
app/Jobs/NFusionSyncTenantPricesJob.php | Queued job wrapper |
app/SyncTargets/ | Provider implementations |
app/Models/NFusionTenant.php | Tenant model |
app/Models/NFusionSyncTarget.php | Sync target model |
app/Models/NFusionSyncLog.php | Sync log model |
config/nfusion.php | Timeout and global nFusion settings |