Package Exports
- google-merchant-feed
- google-merchant-feed/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (google-merchant-feed) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Google Merchant Feed 🛍️
A simple library to generate Google Merchant XML Feed
Installation
npm install google-merchant-feed
Usage
import { FeedBuilder } from "google-merchant-feed";
const feedBuilder = new FeedBuilder();
feedBuilder.withTitle("Test Store");
feedBuilder.withLink("https://example.com");
feedBuilder.withDescription("An example item from the feed");
feedBuilder.withProduct({
id: "DB_1",
title: "Dog Bowl In Blue",
description: "Solid plastic Dog Bowl in marine blue color",
link: "http://www.example.com/bowls/db-1.html",
imageLink: "http://images.example.com/DB_1.png",
availability: "in_stock",
price: {
currency: "GBP",
value: 9.99,
},
shipping: {
country: "UK",
service: "Standard",
price: {
currency: "GBP",
value: 4.95,
},
},
googleProductCategory: "Animals > Pet Supplies",
customLabels: ["Made in Waterford, IE"],
// Other fields
});
// More products
feedBuilder.withProduct({
// ...
});
const xml = feedBuilder.buildXml();
console.log(xml);
Example
XML generated by the code above:
<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:g="http://base.google.com/ns/1.0" version="2.0">
<channel>
<title>Test Store</title>
<link>https://example.com</link>
<description>An example item from the feed</description>
<item>
<g:id>DB_1</g:id>
<g:title>Dog Bowl In Blue</g:title>
<g:description>Solid plastic Dog Bowl in marine blue color</g:description>
<g:link>http://www.example.com/bowls/db-1.html</g:link>
<g:image_link>http://images.example.com/DB_1.png</g:image_link>
<g:availability>in_stock</g:availability>
<g:price>9.99 GBP</g:price>
<g:google_product_category>Animals > Pet Supplies</g:google_product_category>
<g:custom_label_0>Made in Waterford, IE</g:custom_label_0>
<g:shipping>
<g:country>UK</g:country>
<g:service>Standard</g:service>
<g:price>4.95 GBP</g:price>
</g:shipping>
</item>
</channel>
</rss>