Algolia Product Pricing
The Dealers Site uses Algolia as its search and product-browse engine. Product prices are stored in the Algolia index and updated in near-real time by the Middleware Platform's pricing sync. Prices are calculated by the SDM Middleware using nFusion data, then synced to Algolia, ensuring dealers always see current pricing in search results without requiring a WooCommerce page refresh.
Architecture
nFusion API → Middleware (PriceSyncService — calculates prices)
│
POST /suma/v1/prices (import to dealer site)
│
WooCommerce Product Meta (_price, _markup_rate, _volume_pricing)
│
AlgoliaSyncTargetProvider (reads calculated prices from meta)
│
Algolia Search Index (dealer_products)
│
WP Search with Algolia plugin
│
InstantSearch.js (frontend)
│
Dealer browser — live pricing displayed
How Prices Get Into Algolia
- The SDM Middleware fetches nFusion data (ask prices, volume tiers, spot prices, markups) every 5 minutes.
- The PriceSyncService calculates final dealer prices (spot + markup + adjustments) and generates volume tier breakpoints.
- Calculated prices are imported into the Dealer Site via
POST /suma/v1/prices, storing them in WooCommerce product meta. - The AlgoliaSyncTargetProvider reads the calculated prices from product meta and syncs them to Algolia object attributes.
- 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.