Add To Cart
Info
This feature was designed to be super fast thanks to new, improved persistent caching mechanism and carefully designed split of the logic between the server and the client.
Persistent Cache
Add to cart is still based on SFI Pricing Engine, so that the pring logic is consistent and configured in single place - EPC. As any caching solution, it requires pricing to be ran once for each product configuration. Results are stored in sfix__CpqCacheResponse__c
and used later whenever cache key is a match.
Whenever you want to make sure that cache is using latest pricing results, eg. after configuring new prices, delete records in sfix__CpqCacheResponse__c
. For now this feature is not supporting future price changes (ie. cache has to be erased when new prices apply).
Because of SF limitations, SFIX is splitting Pricing Engine response to store it in persistent cache (multiple cache entries for single product). You can control this mechanism by changing default configuration with sfix__CPQCachingMaping__mdt
metadata.
Here is default configuration:
- sfix__StructureNode__c=
lineItems
, sfix__FieldName__c=vlocity_cmt__LineNumber__c
- sfix__StructureNode__c=
productGroups
, sfix__FieldName__c=null
(blank)- sfix__StructureNode__c=
attributeCategories
, sfix__FieldName__c=null
(blank)- sfix__StructureNode__c=
childProducts
, sfix__FieldName__c=null
(blank)
In case of complex EPC configurations cpq response needs to be split more granularly, eg.:
- sfix__StructureNode__c=
productGroups
, sfix__FieldName__c=productId
- in case of number of virtual child products with numerous default products- sfix__StructureNode__c=
childProducts
, sfix__FieldName__c=productId
- in case of numerous optional child products
Implementation Logic
Implementation is split between the server and the client.
- Client side Flex Card:
- fire
sfixAddItemsToCartWithSetAttribute
Integration Procedure
- fire
- Server side Integration Procedure:
- compute cache key
- check if value for the cache key is stored in persistent cache
- read cached values and send them to client
- run out-of-the-box add to cart logic otherwise
- store values in cache
- send out-of-the-box response to client
- Client side Flex Card:
- process the response and display results
sfixAddItemsToCartWithSetAttribute
Integration Procedure:
Automatic invalidation of cache entries
SFIX will evaluate cache entry each time there will be a match. Before returning matching cache entry SFIX will check if there was any price change since the cache entry was created. In case when price will be changed, outdated cache entry will be deleted, pricing engine will be ran, and new value will be automatically stored.
There is no need to maintain, refresh cache or run any batch jobs.
Currently automatic invalidation of cache does not cover Attribute Based Pricing.