Skip to main content

Get Products

Usage

Fetch product data by product IDs.

By default, this method retrieves products through the recommendations engine (recently viewed). To fetch products directly by their IDs without going through the recommendations engine, use the direct: true option.

window.FastSimonSDK.getProducts({
productIds: ["123","456","234235"],
direct: true,
callback: (result) => {
// handle here
}
});

Example (Promise)

const products = await window.FastSimonSDK.getProducts({
productIds: ["123","456","234235"],
direct: true
});

Example (Default - via Recommendations)

// Legacy behavior: fetches products through the recommendations engine.
// Products must be indexed and the recently-viewed widget must be configured.
window.FastSimonSDK.getProducts({
productIds: ["123","456","234235"],
callback: (result) => {
// handle here
}
});

Options

OptionTypeDescription
productIdsstring[] (required)A list of product id's to fetch
callback(Response) => void (required when promise is not used)Callback to handle the results
directbooleanWhen true, fetches products directly by ID. Recommended for most use cases. Default: false (uses recommendations engine)
withAttributesbooleanWhen true, includes product attributes in the response. Only available with direct: true
withBadgesbooleanWhen true, appends a badges array to each product with the matched site badges. Automatically enables withAttributes.

Response

TypeScript Typing
type Response = Product[]

Getting All Product Images via Custom Attributes

By default, each product includes:

  • product.t — main/thumbnail image URL
  • product.t2 — fallback image URL

To retrieve all product images, the Fast Simon team must first enable the "Product images" custom attribute for your store. This is a server-side configuration — it is not self-service.

To request this: Contact support@fastsimon.com and ask to enable product images as a custom attribute.

Once enabled, use withAttributes: true with direct: true to receive the full image list:

window.FastSimonSDK.getProducts({
productIds: ["123", "456"],
direct: true,
withAttributes: true,
callback: (products) => {
products.forEach((product) => {
const imagesAttr = product.attributes?.find(([key]) => key === "Product images");
const allImages = imagesAttr ? imagesAttr[1] : [];
console.log("All images for", product.l, ":", allImages);
});
}
});

The attributes field is an array of [attributeName, values] tuples. The "Product images" entry contains an array of all image URLs for the product.