### Install Product Catalog Feed Package Source: https://github.com/alexvdtrave/product-catalog-feed/blob/main/README.md Add this to your .npmrc file to configure the npm registry. Then, install the package using npm. ```shell @alexvdtrave:registry=https://npm.pkg.github.com ``` ```shell npm install @alexvdtrave/product-catalog-feed ``` -------------------------------- ### Install Product Catalog Feed Library Source: https://context7.com/alexvdtrave/product-catalog-feed/llms.txt Add the GitHub Packages registry to your .npmrc file and install the library using npm. ```bash # Add GitHub Packages registry for the @alexvdtrave scope echo "@alexvdtrave:registry=https://npm.pkg.github.com" >> .npmrc npm install @alexvdtrave/product-catalog-feed ``` -------------------------------- ### Define Product Installment Plan Source: https://context7.com/alexvdtrave/product-catalog-feed/llms.txt Use `ProductInstallment` to describe a monthly payment plan, including the number of months and the per-month amount. This is useful for markets where installment pricing is common. ```javascript import { Product, ProductPrice, ProductInstallment, } from '@alexvdtrave/product-catalog-feed'; const installment = new ProductInstallment( 12, // 12 monthly payments new ProductPrice(54.17, 'USD'), // $54.17/month ); const product = new Product(); product.id = 'sku-phone-pro'; product.title = 'SmartPhone Pro'; product.price = new ProductPrice(650.00, 'USD'); product.installment = installment; product.condition = Product.CONDITION.NEW; product.availability = Product.AVAILABILITY.IN_STOCK; // XML output includes: // // 12 // 54.17 USD // ``` -------------------------------- ### Generate Product Catalog Feed XML Source: https://github.com/alexvdtrave/product-catalog-feed/blob/main/README.md Example demonstrating how to create product objects and build an XML feed using the FeedBuilder. Ensure all required product properties are set. ```javascript import { Product, ProductPrice, FeedBuilder } from '@alexvdtrave/product-catalog-feed'; const pickwick = new Product(); pickwick.id = 'id-pickwick-papers-dickens'; pickwick.title = 'The Pickwick Papers: Charles Dickens'; pickwick.brand = 'Penguin Clothbound Classics'; pickwick.condition = Product.CONDITION.NEW; pickwick.availability = Product.AVAILABILITY.PREORDER; pickwick.price = new ProductPrice(15.99, 'USD'); const hesse = new Product(); hesse.id = 'id-glass-bead-game-hesse'; hesse.title = 'The Glass Bead Game: Hermann Hesse'; hesse.brand = 'Vintage Classics'; hesse.condition = Product.CONDITION.NEW; hesse.availability = Product.AVAILABILITY.IN_STOCK; hesse.price = new ProductPrice(10.99, 'USD'); const xml = new FeedBuilder() .withTitle('Books') .withLink('https://www.example.com') .withDescription('My books') .withProduct(pickwick) .withProduct(hesse) .buildXml(); ``` -------------------------------- ### Set Product Sale Date Range Source: https://context7.com/alexvdtrave/product-catalog-feed/llms.txt Use `ProductDateRange` to define the start and end dates for a product's sale price. Both dates must be `Date` instances. ```javascript import { ProductDateRange } from '@alexvdtrave/product-catalog-feed'; import { Product, ProductPrice } from '@alexvdtrave/product-catalog-feed'; const saleWindow = new ProductDateRange( new Date('2025-12-20T00:00:00Z'), // sale starts new Date('2025-12-26T23:59:59Z'), // sale ends ); const product = new Product(); product.price = new ProductPrice(99.99, 'USD'); product.salePrice = new ProductPrice(59.99, 'USD'); product.salePriceEffectiveDate = saleWindow; // XML output: // 59.99 USD // 2025-12-20T00:00:00.000Z/2025-12-26T23:59:59.000Z ``` -------------------------------- ### Instantiate and Populate Product Model Source: https://context7.com/alexvdtrave/product-catalog-feed/llms.txt Use this snippet to create a new Product instance and set its various attributes. Ensure all required fields are populated according to the product catalog feed specifications. ```javascript import { Product, ProductPrice, ProductDateRange, ProductInstallment, ProductLoyaltyPoints, ProductShipping, ProductTax, UnitPricingMeasure, ShippingWeight, ShippingDimension, } from '@alexvdtrave/product-catalog-feed'; const product = new Product(); // Identity product.id = 'sku-laptop-x1'; product.title = 'UltraBook X1 Laptop'; product.description = '15" laptop with 32GB RAM and 1TB SSD'; product.link = 'https://tech.example.com/laptop-x1'; product.imageLink = 'https://tech.example.com/images/laptop-x1.jpg'; product.mobileLink = 'https://m.tech.example.com/laptop-x1'; product.additionalImageLink = [ 'https://tech.example.com/images/laptop-x1-side.jpg', 'https://tech.example.com/images/laptop-x1-open.jpg', ]; // Availability & expiry product.availability = Product.AVAILABILITY.PREORDER; product.availabilityDate = new Date('2025-09-01T00:00:00Z'); product.expirationDate = new Date('2026-01-01T00:00:00Z'); // Pricing product.price = new ProductPrice(1299.99, 'USD'); product.salePrice = new ProductPrice(999.99, 'USD'); product.salePriceEffectiveDate = new ProductDateRange( new Date('2025-11-01T00:00:00Z'), new Date('2025-11-30T23:59:59Z'), ); product.costOfGoodsSold = new ProductPrice(650.00, 'USD'); // Classification product.brand = 'TechCorp'; product.gtin = ['00012345678905']; product.mpn = 'TCX1-2025'; product.condition = Product.CONDITION.NEW; product.googleProductCategory = 'Electronics > Computers > Laptops'; product.productType = ['Computers > Laptops', 'Sale Items']; // Audience product.ageGroup = Product.AGE_GROUP.ADULT; product.gender = Product.GENDER.UNISEX; // Campaigns product.customLabels = ['sale', 'flagship', undefined, undefined, undefined]; product.promotionId = ['FALL25', 'TECH10']; product.includedDestination = Product.ADS_DESTINATION.SHOPPING; product.adwordsRedirect = 'https://tech.example.com/laptop-x1?utm_source=google'; // Identifiers product.identifierExists = true; product.multipack = 1; product.isBundle = false; ``` -------------------------------- ### Configure Product Loyalty Points Source: https://context7.com/alexvdtrave/product-catalog-feed/llms.txt Use `ProductLoyaltyPoints` to specify the loyalty reward details, including the program name, points awarded, and the cash conversion ratio. The ratio defaults to 1.0 if not provided. ```javascript import { Product, ProductPrice, ProductLoyaltyPoints, } from '@alexvdtrave/product-catalog-feed'; const loyalty = new ProductLoyaltyPoints( 'ShopRewards', // program name 500, // points awarded on purchase 0.01, // each point = $0.01 ); const product = new Product(); product.id = 'sku-sneaker-001'; product.title = 'Running Shoes'; product.price = new ProductPrice(89.99, 'USD'); product.condition = Product.CONDITION.NEW; product.availability = Product.AVAILABILITY.IN_STOCK; product.loyaltyPoints = loyalty; // XML output includes: // // ShopRewards // 500 // 0.0 // ``` -------------------------------- ### Instantiate ProductPrice Source: https://context7.com/alexvdtrave/product-catalog-feed/llms.txt Create a ProductPrice object with a numeric value and an ISO 4217 currency code. This is used for various monetary values within the product catalog. ```javascript import { ProductPrice } from '@alexvdtrave/product-catalog-feed'; const price = new ProductPrice(49.99, 'EUR'); console.log(price.price); // 49.99 console.log(price.currency); // 'EUR' // In XML output the value is formatted as "49.99 EUR" ``` -------------------------------- ### Build Realistic Apparel Product and Generate Feed XML Source: https://context7.com/alexvdtrave/product-catalog-feed/llms.txt This snippet demonstrates how to construct a detailed product object with various attributes including pricing, shipping, tax, loyalty points, and size variations. It then uses FeedBuilder to generate an XML feed and writes it to a file. Ensure all necessary imports are present. ```javascript import { writeFileSync } from 'fs'; import { Product, ProductPrice, ProductDateRange, ProductLoyaltyPoints, ProductShipping, ProductTax, ShippingWeight, FeedBuilder, } from '@alexvdtrave/product-catalog-feed'; // --- Build product --- const jacket = new Product(); jacket.id = 'sku-jacket-red-m'; jacket.title = 'Puffer Jacket - Red / M'; jacket.description = 'Water-resistant puffer jacket, 650-fill down, slim fit'; jacket.link = 'https://shop.example.com/jacket-red-m'; jacket.imageLink = 'https://cdn.example.com/jacket-red-front.jpg'; jacket.additionalImageLink = [ 'https://cdn.example.com/jacket-red-back.jpg', 'https://cdn.example.com/jacket-red-detail.jpg', ]; jacket.brand = 'ArcticLine'; jacket.gtin = ['00854510005643']; jacket.condition = Product.CONDITION.NEW; jacket.availability = Product.AVAILABILITY.IN_STOCK; jacket.googleProductCategory = 'Apparel & Accessories > Clothing > Outerwear'; jacket.itemGroupId = 'jacket-puffer-red'; jacket.color = 'Red'; jacket.size = 'M'; jacket.sizeSystem = Product.SIZE_SYSTEM.US; jacket.sizeType = Product.SIZE_TYPE.REGULAR; jacket.gender = Product.GENDER.UNISEX; jacket.ageGroup = Product.AGE_GROUP.ADULT; jacket.material = 'Nylon'; jacket.price = new ProductPrice(189.99, 'USD'); jacket.salePrice = new ProductPrice(139.99, 'USD'); jacket.salePriceEffectiveDate = new ProductDateRange( new Date('2025-11-28T00:00:00Z'), new Date('2025-12-02T23:59:59Z'), ); jacket.loyaltyPoints = new ProductLoyaltyPoints('ShopRewards', 140, 0.01); const shipping = new ProductShipping(new ProductPrice(0.00, 'USD')); shipping.country = 'US'; shipping.service = 'Standard'; jacket.shipping = shipping; jacket.shippingWeight = new ShippingWeight(1.2, 'kg'); const tax = new ProductTax(); tax.country = 'US'; tax.region = 'CA'; tax.rate = 9.5; tax.taxShip = false; jacket.tax = tax; jacket.customLabels = ['black-friday', 'outerwear', undefined, undefined, undefined]; jacket.promotionId = 'BF2025'; // --- Build feed --- const xml = new FeedBuilder() .withTitle('Example Apparel Feed') .withLink('https://shop.example.com') .withDescription('Current season apparel catalog') .withProduct(jacket) .buildXml(); writeFileSync('feed.xml', xml, 'utf-8'); console.log('Feed written to feed.xml'); ``` -------------------------------- ### Run Tests and Lint Source: https://github.com/alexvdtrave/product-catalog-feed/blob/main/README.md Commands to execute the project's test suite and run the linter to check code quality. ```shell npm test ``` ```shell npm run lint ``` -------------------------------- ### Product Size Type and System Constants Source: https://context7.com/alexvdtrave/product-catalog-feed/llms.txt Constants for specifying product size types (e.g., REGULAR, PETITE) and size systems (e.g., US, EU). ```javascript Product.SIZE_TYPE.REGULAR // 'regular' Product.SIZE_TYPE.PETITE // 'petite' Product.SIZE_TYPE.PLUS // 'plus' Product.SIZE_TYPE.BIG // 'big' Product.SIZE_TYPE.TALL // 'tall' Product.SIZE_TYPE.MATERNITY // 'maternity' Product.SIZE_SYSTEM.US // 'US' Product.SIZE_SYSTEM.EU // 'EU' Product.SIZE_SYSTEM.UK // 'UK' Product.SIZE_SYSTEM.AU // 'AU' Product.SIZE_SYSTEM.JP // 'JP' // ... also BR, CN, DE, FR, IT, MEX ``` -------------------------------- ### Product Condition Constants Source: https://context7.com/alexvdtrave/product-catalog-feed/llms.txt Use these constants to specify the condition of the product. Choose from NEW, REFURBISHED, or USED. ```javascript Product.CONDITION.NEW // 'new' Product.CONDITION.REFURBISHED // 'refurbished' Product.CONDITION.USED // 'used' ``` -------------------------------- ### Product Availability Constants Source: https://context7.com/alexvdtrave/product-catalog-feed/llms.txt Use these constants to set the product's availability status. Ensure the correct string value is used for each status. ```javascript Product.AVAILABILITY.IN_STOCK // 'in stock' Product.AVAILABILITY.OUT_OF_STOCK // 'out of stock' Product.AVAILABILITY.PREORDER // 'preorder' ``` -------------------------------- ### Configure Unit Pricing and Shipping Dimensions Source: https://context7.com/alexvdtrave/product-catalog-feed/llms.txt Utilize UnitPricingMeasure, ShippingWeight, and ShippingDimension to specify unit pricing, package weight, and dimensions for products. The price is shown per unit defined by unitPricingBaseMeasure. ```javascript import { Product, ProductPrice, UnitPricingMeasure, ShippingWeight, ShippingDimension, } from '@alexvdtrave/product-catalog-feed'; // Unit pricing: sell olive oil by the litre const product = new Product(); product.id = 'sku-olive-oil-500ml'; product.title = 'Extra Virgin Olive Oil 500ml'; product.price = new ProductPrice(12.99, 'USD'); product.condition = Product.CONDITION.NEW; product.availability = Product.AVAILABILITY.IN_STOCK; // Actual volume of this SKU product.unitPricingMeasure = new UnitPricingMeasure(500, 'ml'); // Reference denominator — price shown "per 1l" product.unitPricingBaseMeasure = new UnitPricingMeasure(1, 'l'); // Physical package product.shippingWeight = new ShippingWeight(0.75, 'kg'); product.shippingLength = new ShippingDimension(25, 'cm'); product.shippingWidth = new ShippingDimension(8, 'cm'); product.shippingHeight = new ShippingDimension(8, 'cm'); ``` -------------------------------- ### Build a Product Feed with FeedBuilder Source: https://context7.com/alexvdtrave/product-catalog-feed/llms.txt Use FeedBuilder to set feed-level metadata and add individual products with strongly-typed properties. The buildXml() method generates the final RSS XML. ```javascript import { Product, ProductPrice, FeedBuilder, } from '@alexvdtrave/product-catalog-feed'; const shirt = new Product(); shirt.id = 'sku-tshirt-001'; shirt.title = 'Classic White T-Shirt'; shirt.description = 'Comfortable 100% cotton unisex tee'; shirt.link = 'https://shop.example.com/products/tshirt-001'; shirt.imageLink = 'https://shop.example.com/images/tshirt-001.jpg'; shirt.brand = 'ExampleBrand'; shirt.condition = Product.CONDITION.NEW; shirt.availability = Product.AVAILABILITY.IN_STOCK; shirt.price = new ProductPrice(19.99, 'USD'); const xml = new FeedBuilder() .withTitle('Example Store Feed') .withLink('https://shop.example.com') .withDescription('All products from Example Store') .withProduct(shirt) .buildXml(); console.log(xml); // // // // Example Store Feed // https://shop.example.com // All products from Example Store // // sku-tshirt-001 // Classic White T-Shirt // Comfortable 100% cotton unisex tee // https://shop.example.com/products/tshirt-001 // https://shop.example.com/images/tshirt-001.jpg // in stock // 19.99 USD // ExampleBrand // new // // // ``` -------------------------------- ### Batch Add Products to Feed Source: https://context7.com/alexvdtrave/product-catalog-feed/llms.txt Use the `withProducts()` method on FeedBuilder to add an array of Product objects to the feed efficiently. This method throws an error if the argument is not an array. ```javascript import { Product, ProductPrice, FeedBuilder, } from '@alexvdtrave/product-catalog-feed'; function makeProduct(id, title, priceCents, currency) { const p = new Product(); p.id = id; p.title = title; p.condition = Product.CONDITION.NEW; p.availability = Product.AVAILABILITY.IN_STOCK; p.price = new ProductPrice(priceCents / 100, currency); return p; } const products = [ makeProduct('sku-001', 'Blue Mug', 1299, 'USD'), makeProduct('sku-002', 'Red Mug', 1399, 'USD'), makeProduct('sku-003', 'Green Mug', 999, 'USD'), ]; const xml = new FeedBuilder() .withTitle('Mug Store') .withLink('https://mugs.example.com') .withDescription('Colorful mugs') .withProducts(products) // batch-add all products .buildXml(); ``` -------------------------------- ### Product Gender Constants Source: https://context7.com/alexvdtrave/product-catalog-feed/llms.txt Use these constants to specify the gender the product is intended for. Options include MALE, FEMALE, and UNISEX. ```javascript Product.GENDER.MALE // 'male' Product.GENDER.FEMALE // 'female' Product.GENDER.UNISEX // 'unisex' ``` -------------------------------- ### Product Age Group Constants Source: https://context7.com/alexvdtrave/product-catalog-feed/llms.txt Use these constants to define the target age group for the product. Options range from NEWBORN to ADULT. ```javascript Product.AGE_GROUP.NEWBORN // 'newborn' Product.AGE_GROUP.INFANT // 'infant' Product.AGE_GROUP.TODDLER // 'toddler' Product.AGE_GROUP.KIDS // 'kids' Product.AGE_GROUP.ADULT // 'adult' ``` -------------------------------- ### Define Product Shipping Rules Source: https://context7.com/alexvdtrave/product-catalog-feed/llms.txt Use `ProductShipping` to define shipping rules, specifying destination country/region, service level, and cost. An array can be used for multiple shipping destinations. Physical dimensions and handling times can also be set. ```javascript import { Product, ProductPrice, ProductShipping, ShippingWeight, ShippingDimension, } from '@alexvdtrave/product-catalog-feed'; const usShipping = new ProductShipping(new ProductPrice(0.00, 'USD')); usShipping.country = 'US'; usShipping.service = 'Standard'; const caShipping = new ProductShipping(new ProductPrice(9.99, 'USD')); caShipping.country = 'CA'; caShipping.region = 'ON'; caShipping.service = 'Express'; const product = new Product(); product.id = 'sku-book-001'; product.title = 'Learning JavaScript'; product.price = new ProductPrice(34.99, 'USD'); product.condition = Product.CONDITION.NEW; product.availability = Product.AVAILABILITY.IN_STOCK; product.shipping = [usShipping, caShipping]; // multiple shipping rules // Physical dimensions for accurate carrier calculations product.shippingWeight = new ShippingWeight(0.5, 'kg'); product.shippingLength = new ShippingDimension(22, 'cm'); product.shippingWidth = new ShippingDimension(14, 'cm'); product.shippingHeight = new ShippingDimension(3, 'cm'); product.minHandlingTime = 1; // days product.maxHandlingTime = 3; product.shippingLabel = 'lightweight'; // XML output includes two blocks plus dimensions ``` -------------------------------- ### Product Ads Destination Constants Source: https://context7.com/alexvdtrave/product-catalog-feed/llms.txt Use these constants to specify the destinations where the product ads are included. Options include Shopping, ShoppingActions, and DisplayAds. ```javascript Product.ADS_DESTINATION.SHOPPING // 'Shopping' Product.ADS_DESTINATION.SHOPPING_ACTIONS // 'ShoppingActions' Product.ADS_DESTINATION.DISPLAY_ADS // 'DisplayAds' ``` -------------------------------- ### Define Product Tax Rules Source: https://context7.com/alexvdtrave/product-catalog-feed/llms.txt Use ProductTax to define tax rules for specific countries or regions. Assign an array of ProductTax instances for multi-jurisdiction rules. ```javascript import { Product, ProductPrice, ProductTax, } from '@alexvdtrave/product-catalog-feed'; const stateTax = new ProductTax(); stateTax.country = 'US'; stateTax.region = 'CA'; // California stateTax.rate = 8.25; // percent stateTax.taxShip = false; const federalTax = new ProductTax(); federalTax.country = 'CA'; // Canada federalTax.rate = 5.00; // GST federalTax.taxShip = true; const product = new Product(); product.id = 'sku-widget-001'; product.title = 'Gadget Widget'; product.price = new ProductPrice(24.99, 'USD'); product.condition = Product.CONDITION.NEW; product.availability = Product.AVAILABILITY.IN_STOCK; product.tax = [stateTax, federalTax]; product.taxCategory = 'electronics'; ``` -------------------------------- ### Generated Product Catalog Feed XML Source: https://github.com/alexvdtrave/product-catalog-feed/blob/main/README.md The resulting XML document generated from the provided JavaScript code. This format is compatible with Google Merchant Center and Facebook Business. ```xml Books https://www.example.com My books id-pickwick-papers-dickens The Pickwick Papers: Charles Dickens preorder 15.99 USD Penguin Clothbound Classics new id-glass-bead-game-hesse The Glass Bead Game: Hermann Hesse in stock 10.99 USD Vintage Classics new ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.