Broadleaf Microservices
  • v1.0.0-latest-prod

Products

Products are one of the main entities you will be working with. These are the physical and digital goods that you are selling.

Get Product

Operation

BrowseClient#getProduct(productFetchParams, options);

Parameters

Parameter Type Required? Description

productFetchParams

ProductFetchParams

Provide a product id or product url to fetch

options

BrowseClientCallOptions

Options passed to the HTTP request call to customize the request configuration.

Response

This function returns a Product.

Example

Example of retrieving a product by its uri
const product = await browseClient.getProduct({
  uri: '/hot-sauces/green_ghost'
});

console.log(product);

Get Product By Url

Operation

BrowseClient#getProductByUrl(url, options);

Parameters

Parameter Type Required? Description

url

string

Provide a product url to fetch

options

BrowseClientCallOptions

Options passed to the HTTP request call to customize the request configuration.

Response

This function returns a Product.

Example

Example of retrieving a product by its url
const product = await browseClient.getProductByUrl('/hot-sauces/green_ghost');

console.log(product);

Get Product By Id

Operation

BrowseClient#getProductById(id, options);

Parameters

Parameter Type Required? Description

id

string

Provide a product id to fetch

options

BrowseClientCallOptions

Options passed to the HTTP request call to customize the request configuration.

Response

This function returns a Product.

Example

Example of retrieving a product by its id
const product = await browseClient.getProductById('123');

console.log(product);

List Products

Operation

BrowseClient#listProducts(productListParams, options);

Parameters

Parameter Type Required? Description

productListParams

ListProductsParams

Provide a list of product ids or product uris to retrieve

options

BrowseClientCallOptions

Options passed to the HTTP request call to customize the request configuration.

Response

This function returns a list of Products.

Example

Example of retrieving products by providing a list of uri’s:
const products = await browseClient.getProducts({
  productUris: [
    '/hot-sauces/green_ghost',
    '/hot-sauces/sudden-death'
  ],
});

console.log(products);