As a retailer, you want your product feeds to process and make it to their destinations as quickly as possible. But efficient feed speed is often the result of the type of business rules at play.
In general, business rules execute at a fast pace. However, highly complex business rules that perform large lookups, run regular expressions repeatedly or run custom functions repeatedly can slow overall feed speed.
Let’s look at an actual Support case we recently received.
This seller had a business rule they used to compute a base price for each SKU. Depending on what that base price was, the rule would take a different action (i.e., set a sale price). To do this, the business rule had to call the custom function multiple times for each SKU, which slowed down the feed significantly. That business rule looked something like this:
This business rule is slow because it calls the GetBasePrice rule five times for every SKU.
It occurred to us that we should be able to call that custom function just once, stash its result somewhere and reuse that result as many times as we’d like. And just like that, a new business rule function was born!
Sellers, meet SETCONTEXTVALUE.
To use this new function, just give it a variable name and a value to stash in that variable. You can use the GETCONTEXTVALUE function later in the business rule to get the value back out of the variable. For example:
This business rule is faster since it calls the GetBasePrice rule only once per SKU.
The new and improved rule has the same functionality, but with a faster processing time. The feed gets a nice speed boost since it’s not having to execute the complex logic in GetBasePrice over and over.
Do you have any logic that’s being called repeatedly inside the same business rule? Give your feed a boost with SETCONTEXTVALUE! The function is now available for use.
Blog post by Lance Robinson, software engineer, Rithum