Algolia Product Pricing
The Dealers Site uses Algolia as its search and product-browse engine. Critically, product prices are stored in the Algolia index and updated in near-real time by the Middleware Platform's pricing sync. This means dealers always see current spot-price-based pricing in search results without requiring a WooCommerce page refresh.
Architecture
nFusion API → Middleware (PriceSyncService)
│
AlgoliaSyncTargetProvider
│
Algolia Search Index (dealer_products)
│
WP Search with Algolia plugin
│
InstantSearch.js (frontend)
│
Dealer browser — live pricing displayed
How Prices Get Into Algolia
- The Middleware Platform fetches live spot prices from nFusion every 5 minutes.
- The AlgoliaSyncTargetProvider maps nFusion price fields to Algolia object attributes (configured via the field mapping in the admin panel).
- Algolia object records are updated via
partialUpdateObjects— only price fields change; product content (descriptions, images, SKU, etc.) remains untouched. - The Dealers Site's InstantSearch.js frontend reads prices directly from the Algolia hit attributes — no WooCommerce page request needed.
Algolia Index
The Dealers Site uses a dedicated Algolia index (separate from the Retail site's index). The index name and credentials are configured in wp-config.php:
define( 'ALGOLIA_APP_ID', 'XXXXXXXXXX' );
define( 'ALGOLIA_API_KEY', 'xxxxxxxx...' ); // Search-only key (frontend)
Admin operations (indexing, price updates) use the Admin API key, which is stored securely in the Middleware Platform's .env.
Algolia Object Attributes (Pricing)
After a sync run, each product object in Algolia contains:
| Attribute | Description |
|---|---|
sku | Product SKU |
regular_price | Standard ask price (from nFusion ask field) |
retail_tiers | Volume pricing tiers (array of {qty, ask, markup}) |
cc_price | Credit card price (if payment adjustment configured) |
wire_price | Wire transfer price (if payment adjustment configured) |
sale_price | Temporary discounted price (if sale overlay active) |
WP Search with Algolia Plugin
The WP Search with Algolia plugin (plugins/wp-search-with-algolia/) provides:
- Index management UI in WP admin
- WordPress search integration (redirects searches to Algolia)
- WooCommerce product indexing hooks
The theme's class-algolia.php and class-algolia-custom-search.php extend the plugin's index classes to customise which post types and attributes are indexed.
Pricing Catalog Override
Dealers can be assigned a pricing catalog (stored as user meta pricing_catalog). When a pricing catalog is assigned:
- The WooCommerce product/cart layer applies the catalog's markup overrides on top of the Algolia-sourced base price.
- Non-catalog dealers see the default prices from the Algolia index.
Pricing catalogs are managed via the custom REST endpoint GET/POST /suma/v1/pricing-catalogs.
Custom Algolia Search Extend
class-algolia-custom-search.php defines Algolia_Searchable_Posts_Index_Not_Products — a custom Algolia index class that indexes non-product posts (pages, posts) while excluding products (which have their own index). This ensures the site's content search returns relevant pages without clogging the product pricing index.