Skip to content

Latest commit

 

History

History
32 lines (25 loc) · 1.3 KB

File metadata and controls

32 lines (25 loc) · 1.3 KB

Rendering Logic & Customizations

Structured data

GTIN & Product Codes

GTIN is strongly recommended in the structured data but not mandatory.

From ldJson.js

/**
 * Extracts the GTIN (Global Trade Item Number) from a product's attributes.
 * Checks for GTIN, UPC, or EAN attributes as defined in the Catalog.
 * 
 * @param {Object} product - The product object containing attributes
 * @returns {string} The GTIN value if found, empty string otherwise
 */
function getGTIN(product) {
  return product?.attributes?.find(attr => attr.name === 'gtin')?.value
    || product?.attributes?.find(attr => attr.name === 'upc')?.value
    || product?.attributes?.find(attr => attr.name === 'ean')?.value
    || product?.attributes?.find(attr => attr.name === 'isbn')?.value
    || '';
}

You can customize this function to use your own logic logic to retrieve the GTIN code, even from external sources, during the rendering process.

Templates

The main customization point to define markup structure is the templates folder Those files follow the Handlebars syntax and the referenced variables can be defined in render.js