An open API service indexing awesome lists of open source software.

https://github.com/douglasgusson/google-merchant-feed

A simple library to generate Google Merchant XML Feed
https://github.com/douglasgusson/google-merchant-feed

feed generator google-merchant xml

Last synced: 4 months ago
JSON representation

A simple library to generate Google Merchant XML Feed

Awesome Lists containing this project

README

          

# Google Merchant Feed 🛍️

A simple library to generate Google Merchant XML Feed

[![npm version](https://badge.fury.io/js/google-merchant-feed.svg)](https://badge.fury.io/js/google-merchant-feed)
![Build status](https://github.com/douglasgusson/google-merchant-feed/actions/workflows/ci.yml/badge.svg)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![NPM Downloads](https://badgen.net/npm/dm/google-merchant-feed)](https://www.npmjs.com/package/google-merchant-feed)

## Installation

```bash
npm install google-merchant-feed
```

## Usage

```typescript
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


Test Store
https://example.com
An example item from the feed

DB_1
Dog Bowl In Blue
Solid plastic Dog Bowl in marine blue color
http://www.example.com/bowls/db-1.html
http://images.example.com/DB_1.png
in_stock
9.99 GBP
Animals > Pet Supplies
Made in Waterford, IE

UK
Standard
4.95 GBP


```