Sub topic 1
How AI shopping answers use product data
Prerequisites
This chapter assumes you have:
- Basic familiarity with e-commerce catalogs and SKUs.
- Some experience reading simple XML, JSON, and tab-separated files.
- A working idea of what a product page is, including basic HTML.
- Comfort running a short Python script.
You do not need a merchant account yet. Later chapters cover account setup, attribute details, and validation.
What a shopping answer is made of
A user asks an assistant, "What is a good lightweight rain jacket under $100 for running?" The assistant replies with a few named products, prices, and links to buy. That reply is a shopping answer. It looks like generated text, but the facts inside it come from product data. The assistant needs to know that a product exists, what it is, what it costs, whether it can be bought now, and where.
Two kinds of work happen behind the reply:
- Language work. The system interprets the request, extracts constraints (type: jacket, use: running, budget: under $100), and writes the response.
- Catalog work. The system finds products that satisfy those constraints and checks that the facts are current.
The catalog work depends on structured data, which is data in named fields with predictable formats. A model can guess at a price from a paragraph of text. A shopping system that must show a price a buyer can actually pay needs the price to be a labeled value with a currency. This tutorial is about supplying that data well.
The details of any one assistant's ranking are not public, and they change. Treat the model below as a working picture based on how product data specifications and public merchant documentation are designed, not as a guarantee of any system's behavior.
Three channels that carry product data
Merchants usually publish the same product facts through three channels. Chapter 2 covers them in detail. Here is the overview.
| Channel | What it is | Strength | Typical weakness |
|---|---|---|---|
| Product feed | A file or API upload (XML, TSV, or similar) listing every product with named attributes | Complete, consistent, and under your control | Goes stale between uploads |
| Page markup | schema.org `Product` and `Offer` data embedded in each product page, usually as JSON-LD | Always matches what the page shows, and can be crawled without an account | Coverage depends on crawling, and templates can omit fields |
| Merchant account | The settings and policy data attached to your business: shipping, returns, store identity, and program status | Carries facts that apply to many products at once | Misconfiguration affects the whole catalog |
A shopping system treats these channels as evidence about the same product. When they agree, the system can trust the data. When they disagree, for example a feed price of 89.00 USD against a page price of 99.00 USD, the system has to pick one, drop the item, or flag it for review. That is why consistency gets its own chapter later.
From raw data to an answer
The path from your data to a shopping answer has four stages. The names below are descriptive labels for this tutorial, not official terms.
- Ingestion and checks. The system reads your data and validates it against the specification. Items with missing required attributes or policy problems are rejected or limited. Rejections show up as diagnostics you can read, which Chapter 15 covers.
- Matching and grouping. Many merchants sell the same product. The system uses identifiers such as GTIN (Global Trade Item Number, the barcode number) and brand to recognize that two offers describe one product. It uses
item_group_idto gather size and color variants under one parent. - Retrieval and ranking. For a given request, the system selects candidates whose attributes fit the constraints and orders them. Titles, descriptions, categories, and attributes like color and size supply the text and facets it matches against.
- Answer presentation. The chosen products appear with price, availability, and a link. These are the facts most likely to be wrong when data is stale, so they are the ones most often re-checked.
Each stage can lose your product. A product that is never ingested cannot be matched. A product that is ingested but has a weak title may not be retrieved. A product that is retrieved but shows a stale price may be suppressed or may disappoint the buyer.
A toy example: why identifiers and price fields matter
The script below is a simplified illustration, not how any production system works. It groups offers from three merchants by GTIN and picks the cheapest offer that is in stock. It shows how much a missing or mismatched field changes the outcome.
from collections import defaultdict
offers = [
{"merchant": "StoreA", "gtin": "00012345678905", "price": 89.00, "availability": "in_stock"},
{"merchant": "StoreB", "gtin": "00012345678905", "price": 79.00, "availability": "out_of_stock"},
{"merchant": "StoreC", "gtin": "", "price": 75.00, "availability": "in_stock"},
]
groups = defaultdict(list)
unmatched = []
for offer in offers:
if offer["gtin"]:
groups[offer["gtin"]].append(offer)
else:
unmatched.append(offer)
for gtin, items in groups.items():
available = [o for o in items if o["availability"] == "in_stock"]
if available:
best = min(available, key=lambda o: o["price"])
print(gtin, "->", best["merchant"], best["price"])
else:
print(gtin, "-> no offer in stock")
for offer in unmatched:
print("cannot match:", offer["merchant"], "(no GTIN)")Running it prints:
00012345678905 -> StoreA 89.0
cannot match: StoreC (no GTIN)StoreB has the lowest price but is out of stock, so it never appears. StoreC has a lower price than StoreA but no identifier, so it cannot join the group. Real systems have other ways to match products, such as titles, images, and brand, but those are less reliable than a valid GTIN. Missing identifiers cost you visibility in comparisons.
Where shopping answers go wrong
Most failures come from data, not from the language model. Common causes:
- Stale facts. The feed says
in_stockbut the item sold out an hour ago. The buyer clicks through to an unavailable product. - Cross-channel conflicts. The feed and the page disagree on price, currency, or availability.
- Vague titles. A title like "Jacket" gives retrieval little to match against "lightweight running rain jacket."
- Missing identifiers. Without GTIN or brand, the item may not be grouped with comparable offers.
- Broken variants. Without a shared
item_group_id, each size and color looks like an unrelated product. - Account-level gaps. Missing shipping or return settings can limit or block every product, however good the item data is.
How the rest of the tutorial maps to this pipeline
The remaining chapters follow the stages above:
- Chapters 2 to 3 cover the data sources and the product data model, which feed ingestion.
- Chapters 4 to 8 cover identifiers, titles, price, variants, and shipping. These drive matching and retrieval.
- Chapters 9 to 11 cover account setup, feed formats, and schema.org markup, which are the delivery channels.
- Chapters 12 to 16 cover consistency, freshness, validation, diagnostics, and measurement, which keep the data trustworthy over time.
Exercise
A merchant's feed lists a jacket at 89.00 USD, in stock, with a valid GTIN. The product page shows 99.00 USD. Name two pipeline stages where this could cause a problem, and say what a shopping system might do.
Show answer
At ingestion and checks, the mismatch between feed and landing page can trigger a price-mismatch policy flag, which may disapprove the item and produce a diagnostic. At answer presentation, if the item is still shown, the buyer sees 89.00 USD in the answer and 99.00 USD on the page, which breaks trust and can lead the system to suppress the offer. The fix is to make the feed and the page agree, which Chapter 12 covers.
Exercise
In the toy script, StoreC has the lowest price but does not appear in the grouped result. Which field is missing, and which pipeline stage does it affect?
Show answer
The GTIN is missing. It affects matching and grouping, because without an identifier the offer cannot be reliably joined to the same product as the other merchants' offers.