diff --git a/prerender/seo/feeds.cjs b/prerender/seo/feeds.cjs index b0ada0e..9f505e4 100644 --- a/prerender/seo/feeds.cjs +++ b/prerender/seo/feeds.cjs @@ -337,11 +337,20 @@ const generateProductsXml = (allProductsData = [], baseUrl, config) => { return; } - // Skip products without GTIN + // Skip products without GTIN or with invalid GTIN if (!product.gtin || !product.gtin.toString().trim()) { skippedCount++; return; } + + // Validate GTIN format (must be numeric and proper length) + const gtinString = product.gtin.toString().trim(); + const isValidGtin = /^\d{8}$|^\d{12}$|^\d{13}$|^\d{14}$/.test(gtinString); + + if (!isValidGtin) { + skippedCount++; + return; + } // Skip products without pictures if (!product.pictureList || !product.pictureList.trim()) {