Sub topic 3
Handling out-of-stock, changed, and discontinued products
A product page changes in three common ways. The item sells out, a detail such as size or material changes, or the item is discontinued. Each change must reach every place that shows the product: the visible page, its Product markup, the sitemap, caches, and feeds. Otherwise shoppers and AI answer systems may see an item that cannot be bought.
Out-of-stock, changed, and discontinued products
Keep the product record as the single source of truth. Derive the availability value from that record, and render both the visible label and the JSON-LD from the same field.
def availability(record):
if record["discontinued"]:
return "https://schema.org/Discontinued"
if record["stock"] > 0:
return "https://schema.org/InStock"
return "https://schema.org/OutOfStock"
record = {"sku": "TR2-BLK-42", "stock": 0, "discontinued": False}
print(availability(record))For a temporarily unavailable item, keep the page live and show when it returns. For a product that will not return, either send a 410 Gone response or a 301 redirect to a true replacement. Do not redirect to an unrelated category.
Accurate lastmod values in sitemaps
Set <lastmod> to the date of the last meaningful change to price, stock, or description. Trivial edits should not move it, because a false date erodes trust in the sitemap.
Cache-Control, ETag, and Last-Modified
Cache-Control: max-age=300 lets a cache reuse a copy for five minutes without asking the server. ETag is a fingerprint of the content. Last-Modified is the date of the last change. When these values change, caches can detect that their copy is stale.
Making sure caches and CDNs serve the new facts
After a price or stock change, purge the product URL from the CDN. Use a shorter max-age on pages whose prices change often.
Product feeds
Generate merchant feeds from the same record as the page. Run a nightly comparison so that a feed price never differs from the page price.
Owners and change workflows
Assign an owner to each fact type, such as prices or stock. Set a review cadence, for example monthly for prices. Each change goes through the record, a review, publication, and a log entry.
Automated checks for drift
A drift check compares the record with the page markup, sitemap, and feed.
Exercise
A product's price dropped from 89.00 EUR to 79.00 EUR. The record and the visible page show 79.00, but the JSON-LD still says 89.00. Which values should the drift check compare, and what should it report?
Show answer
It should compare the record price with the JSON-LD price, and the visible page price with both. It should report that the JSON-LD is stale, and it should flag a feed or sitemap whose price or lastmod does not match the change.