Product Factory
Product factory provides builder methods to help you create Firework product objects from any third-party format. Firework product objects are required for Product Hydration and Cart Sync.

Name | Description | Required |
---|---|---|
extId | External ID in a partner database. It is used to match and update products synced with Firework. | Yes |
name | Product name | Yes |
description | Product description. Markdown for rich formating is allowed. | Yes |
currency | Currency code. e.g. "USD". | Yes |
variant | Yes, at least one variant should exist in a product |
Sample Code
window._fwn.shopping.productFactory((builder) => {
builder
.description(remoteProduct.description)
.extId(remoteProduct.id)
.name(remoteProduct.title)
.currency('USD')
.variant((variantBuilder) => {
// See "Create a variant" section.
})
})
Every product can have one or more variants. For example, a product may come in different sizes or colors. Please note each product needs at least one variant.
Name | Description | Required |
---|---|---|
extId | External variant ID in a partner database. It is used to match and update product variants synced with Firework. | Yes |
url | URL to product/variant detail page. | Yes |
price | Numeric value of current price | Yes |
sku | SKU identifier. | Optional |
name | Variant name. | Optional |
originalPrice | Numeric value of original price | Optional |
isAvailable | Boolean indicating whether variant is currently available (out of stock). | Optional |
image | Optional | |
option | Variant option. Accepts {name, value} object (e.g {name: 'Size', value: 'Large'} ) | Optional |
productbuilder.variant((variantBuilder) => {
variantBuilder
.extId(remoteVariant.id)
.url('https://www.example.com')
.price(remoteVariant.price)
.sku(remoteVariant.sku)
.name(remoteVariant.name)
.isAvailable(remoteVariant.isAvailable)
.image((imageBuilder) => {
// See "Create an image" section
})
remoteVariant.options.forEach(({name, value}) => {
variantBuilder.option({
name,
value,
})
})
})
To update the default pricing, a variant must be hydrated that matches the existing
unit_id
Name | Description | Required |
---|---|---|
extId | External image ID in partner database. It is used to match images between the partner and the Firework database. | Yes |
url | URL location of an image. | Yes |
title | Alt title for an image. | Optional |
position | Numeric value used to sort multiple images. | Optional |
variantBuilder
.image((imageBuilder) => {
imageBuilder
.extId(remoteVariant.featured_image.id)
.position(remoteVariant.featured_image.position)
.title(remoteVariant.featured_image.alt)
.url(remoteVariant.featured_image.src)
})
Last modified 4d ago