As one of the developers of the ShoppingAdvisor product, I’ve been helping people write business rules to clean up and manipulate their inventory data to create comparison shopping feeds for several years now. I thought this blog would be a great way for me to share some of the rules that I’ve helped people write, and along the way try to help others make the most of ShoppingAdvisor’s templates and business rules. If I’m lucky, I’ll be able to make this a regular thing, which means I need a somewhat trite yet pithy byline.
All right then; here’s my inaugural “Ask the Feed Doctor” post. The names and locations have been changed to protect the guilty. “B.” in Natchitoches, La., writes:
Dear Feed Doctor,
All my items have a Condition field, and the value there is either “NIB” (that’s “new in box”), “Pre-Owned,” or “Returned.” The problem is, the shopping engine I want to send my items to requires that the “Stock Description” (that’s what they call the Condition) be either “New”, “Used,” or “Refurb.” Can you help me write a rule to convert these to the proper values?
Merci Beaucoup.
Lookup Lists
The good news for “B.” is that he doesn’t have to write a business rule at all. ShoppingAdvisor’s lookup lists are designed with this very situation in mind. A lookup list, sometimes also called a dictionary, is a lot like a phone book. It’s a table of keys (in the phone book, these would be the names) with associated values (in the phone book, the phone numbers). In our example, the keys are B’s Condition values (”NIB”, “Pre-Owned,” “Returned”) and the keys are the shopping engine’s Stock Description values (”New,” “Used,” “Refurb”). Here’s how B. might define his lookup list in ShoppingAdvisor:

Once B. saves that list, all he has to do now is go to the template for his feed and set it to use that list to fill in the Stock Description value:

Now what about that text box that says “Default value?” Let’s go back to our phone book analogy; sometimes you can’t find a person’s name in the phone book, and that means you can’t find their phone number, either. As far as you’re concerned, they might as well not have a phone number at all. How might this happen with B’s items? Maybe he has a couple of rogue items with a condition of “Mint,” or maybe some with no condition value at all. For these items, the lookup list will just give back a blank value, and since Stock Description is a required field (see that asterisk next to it in the picture above?), that would mean the item wouldn’t be sent to the shopping engine at all.
This is where the default value comes in handy. If B. is 100% sure that any item whose Condition value isn’t “NIB,” “Pre-Owned,” or “Returned” is really a new item, then he can set the default value to “New” and those items will be sent to the shopping engine with their Stock Description set to “New.” On the other hand, if he’s not sure that the items are new, it might be better to leave the default value blank so that items will NOT go to the shopping engine. Of course, the best case scenario would be that B’s items all had Condition values, and that all those possible values were in his lookup list, but we try to give you a safety net when we can.
The Case of the Random Case
Ok, we know what happens if B’s Condition field has values that aren’t in the lookup list. What happens if it doesn’t use case consistently; that is, what if sometimes his new items are “NIB,” and sometimes they’re “nib,” and sometimes they’re “NiB?” Well, again the good news is that our lookup lists are designed to handle this: the list’s keys are case-insensitive. Any of those variations of “NIB” will give back a value of “New” from the lookup list. Note that the case of “New” won’t change; you’re not going to get “NEW” or “new” or “NeW.” Also, because the keys are case-insensitive, you can’t put both “NIB” and “nib” in the list as keys; there’s always a trade-off, isn’t there? And finally, there are a lot of things in ShoppingAdvisor that are NOT case-insensitive, so just keep that in the back of your mind.
Well, that’s it for this edition of “Ask the Feed Doctor.” I hope it was interesting and informative. I’ll answer some more questions soon, and I’d love to get some from our blog audience.
Share This