diff --git a/.changeset/forty-onions-wash.md b/.changeset/forty-onions-wash.md
new file mode 100644
index 0000000..dcc03ea
--- /dev/null
+++ b/.changeset/forty-onions-wash.md
@@ -0,0 +1,7 @@
+---
+"saleor-app-products-feed": minor
+---
+
+Feed format has been changed to leverage Product Group ID field:
+- Product ID: feed items use SKU if available, product variant ID is used otherwise
+- Product Group ID: product ID is used for all the items
diff --git a/apps/products-feed/src/modules/google-feed/generate-google-xml-feed.test.ts b/apps/products-feed/src/modules/google-feed/generate-google-xml-feed.test.ts
index 7a3f892..edc8685 100644
--- a/apps/products-feed/src/modules/google-feed/generate-google-xml-feed.test.ts
+++ b/apps/products-feed/src/modules/google-feed/generate-google-xml-feed.test.ts
@@ -16,6 +16,7 @@ const productBase: GoogleFeedProductVariantFragment["product"] = {
seoDescription: "Seo description",
slug: "product-slug",
thumbnail: { __typename: "Image", url: "" },
+ attributes: [],
};
const priceBase: GoogleFeedProductVariantFragment["pricing"] = {
@@ -46,6 +47,7 @@ describe("generateGoogleXmlFeed", () => {
pricing: priceBase,
name: "Product variant",
product: productBase,
+ attributes: [],
},
{
id: "id2",
@@ -55,6 +57,7 @@ describe("generateGoogleXmlFeed", () => {
pricing: priceBase,
name: "Product variant 2",
product: productBase,
+ attributes: [],
},
],
});
@@ -68,6 +71,7 @@ describe("generateGoogleXmlFeed", () => {
Description
-
sku1
+ product-id
Product - Product variant
new
in_stock
@@ -78,6 +82,7 @@ describe("generateGoogleXmlFeed", () => {
-
sku2
+ product-id
Product - Product variant 2
new
out_of_stock
diff --git a/apps/products-feed/src/modules/google-feed/product-to-proxy.test.ts b/apps/products-feed/src/modules/google-feed/product-to-proxy.test.ts
index 3741a91..edeab11 100644
--- a/apps/products-feed/src/modules/google-feed/product-to-proxy.test.ts
+++ b/apps/products-feed/src/modules/google-feed/product-to-proxy.test.ts
@@ -2,13 +2,13 @@ import { describe, it, expect } from "vitest";
import { productToProxy } from "./product-to-proxy";
describe("productToProxy", () => {
- it("Falls back product ID, if product SKU doesnt exist", () => {
+ it("Falls back product ID, if product SKU doesn't exist", () => {
const result = productToProxy({
slug: "slug",
availability: "in_stock",
category: "1",
condition: "new",
- id: "id",
+ id: "product-id",
name: "Name",
variantId: "variant-id",
});
@@ -16,13 +16,13 @@ describe("productToProxy", () => {
expect(result.item).toEqual(
expect.arrayContaining([
{
- "g:id": expect.arrayContaining([{ "#text": "id" }]),
+ "g:id": expect.arrayContaining([{ "#text": "variant-id" }]),
},
])
);
});
- it('Falls back g:condition to "new" if product condition doesnt exist', () => {
+ it('Falls back g:condition to "new" if product condition doesn\'t exist', () => {
const result = productToProxy({
slug: "slug",
availability: "in_stock",
@@ -31,7 +31,7 @@ describe("productToProxy", () => {
* Missing condition field:
* condition: "new",
*/
- id: "id",
+ id: "product-id",
name: "Name",
variantId: "variant-id",
});
@@ -51,7 +51,7 @@ describe("productToProxy", () => {
availability: "in_stock",
category: "1",
condition: "new",
- id: "id",
+ id: "product-id",
name: "Name",
variantId: "variant-id",
description: "Product description",
@@ -73,7 +73,7 @@ describe("productToProxy", () => {
category: "1",
condition: "new",
googleProductCategory: "1",
- id: "id",
+ id: "product-id",
name: "Name",
variantId: "variant-id",
});
@@ -94,7 +94,7 @@ describe("productToProxy", () => {
category: "1",
condition: "new",
googleProductCategory: "1",
- id: "id",
+ id: "product-id",
name: "Name",
variantId: "variant-id",
storefrontUrlTemplate: "https://example.com/p/{productSlug}/{productId}/{variantId}",
@@ -105,7 +105,7 @@ describe("productToProxy", () => {
{
link: expect.arrayContaining([
{
- "#text": "https://example.com/p/slug/id/variant-id",
+ "#text": "https://example.com/p/slug/product-id/variant-id",
},
]),
},
@@ -120,7 +120,7 @@ describe("productToProxy", () => {
category: "1",
condition: "new",
googleProductCategory: "1",
- id: "id",
+ id: "product-id",
name: "Name",
variantId: "variant-id",
imageUrl: "https://image.example.com",
@@ -142,7 +142,7 @@ describe("productToProxy", () => {
category: "1",
condition: "new",
googleProductCategory: "1",
- id: "id",
+ id: "product-id",
name: "Name",
variantId: "variant-id",
imageUrl: "https://image.example.com",
diff --git a/apps/products-feed/src/modules/google-feed/product-to-proxy.ts b/apps/products-feed/src/modules/google-feed/product-to-proxy.ts
index f4dd8c3..23571af 100644
--- a/apps/products-feed/src/modules/google-feed/product-to-proxy.ts
+++ b/apps/products-feed/src/modules/google-feed/product-to-proxy.ts
@@ -1,15 +1,19 @@
import { fillUrlTemplate } from "../feed-url/fill-url-template";
import { GoogleProxyItem, ProductEntry } from "./types";
-/**
- * TODO Test
- */
export const productToProxy = (p: ProductEntry) => {
const item: GoogleProxyItem[] = [
{
"g:id": [
{
- "#text": p.sku || p.id,
+ "#text": p.sku || p.variantId,
+ },
+ ],
+ },
+ {
+ "g:item_group_id": [
+ {
+ "#text": p.id,
},
],
},