Sub topic 7
Variants and grouping with `item_group_id`
This chapter assumes that you understand SKUs, can read simple XML or JSON, and know that a product page may represent several purchasable versions of one product.
A variant is a purchasable version of a product that differs by an option such as color, size, material, or capacity. Each variant needs its own product record because it can have a different identifier, image, URL, price, or availability.
item_group_id connects those records. It tells a shopping system that several distinct items belong to one variant family. The value should be the same for every variant in the family, while each id must remain unique.
| Attribute | Purpose | Example |
|---|---|---|
| `id` | Identifies one purchasable variant | `JACKET-BLU-M` |
| `item_group_id` | Groups related variants | `JACKET-1001` |
| `color` | Describes the color option | `Blue` |
| `size` | Describes the size option | `M` |
| `link` | Opens the matching variant page | URL with `color=blue&size=m` |
Model the group and its variants
Start with a stable product-family key. Do not use a changing price, title, or URL as the group key. Then generate one item for every combination that customers can actually buy.
For example, a jacket available in blue and green, each in medium and large, has four variants. Every record uses item_group_id value JACKET-1001, but every record has a different id.
<item>
<g:id>JACKET-BLU-M</g:id>
<g:title>Trail Runner Jacket, Blue, Medium</g:title>
<g:link>https://shop.example.com/jacket?color=blue&size=m</g:link>
<g:image_link>https://shop.example.com/images/jacket-blue.jpg</g:image_link>
<g:price>89.00 USD</g:price>
<g:availability>in_stock</g:availability>
<g:item_group_id>JACKET-1001</g:item_group_id>
<g:color>Blue</g:color>
<g:size>M</g:size>
</item>A second record might use the same group but different variant values:
<item>
<g:id>JACKET-GRN-L</g:id>
<g:title>Trail Runner Jacket, Green, Large</g:title>
<g:link>https://shop.example.com/jacket?color=green&size=l</g:link>
<g:image_link>https://shop.example.com/images/jacket-green.jpg</g:image_link>
<g:price>94.00 USD</g:price>
<g:availability>out_of_stock</g:availability>
<g:item_group_id>JACKET-1001</g:item_group_id>
<g:color>Green</g:color>
<g:size>L</g:size>
</item>The second item can have a different price and availability because those values belong to the purchasable variant. Its URL and image should also show the green, large version. Sending a blue image for a green item creates ambiguity and can cause a mismatch with the landing page.
Avoid common grouping errors
- Give every variant a unique
id. Reusing one ID hides or overwrites items. - Use the same
item_group_idfor related variants. Different group values split one family into unrelated products. - Do not group separate products merely because they have similar names.
- Include every option needed to select the exact item, such as
color,size, ormaterial. - Keep the feed values and page controls synchronized. A variant marked in stock must be selectable on its landing page.
Exercise
A shirt has red and black colors in sizes S and M. How many item records should the feed contain, and which values must be shared?
Show answer
It should contain four records, one for each color-and-size combination. All four records share the same item_group_id, but each has a unique id and its own color, size, URL, image, price, and availability.