Skip to main content

Class: ProductCollection

A collection of products that can be used to form a bundle.

Constructors​

Constructor​

new ProductCollection(collection): ProductCollection

Parameters​

collection​

ProductCollectionResource

Returns​

ProductCollection

Methods​

fetchProducts()​

fetchProducts(productIds?): Promise<CollectionProduct[]>

A list of products in this collections with useful helpers for interacting with them.

Parameters​

productIds?​

string[]

Returns​

Promise<CollectionProduct[]>


fetchProductsById()​

fetchProductsById(productIds): Promise<CollectionProduct[] | undefined>

Fetches the CollectionProducts which are linked to the provided Spiff Products.

Parameters​

productIds​

string[]

The IDs of the Spiff Product to locate.

Returns​

Promise<CollectionProduct[] | undefined>


fetchProductsFeed()​

fetchProductsFeed(offset, limit, productFilters?, tags?, sortKey?, sortDescending?, quickSearch?, workflowFilters?): Promise<{ items: CollectionProduct[]; total: number; }>

Fetches a paginated feed of products.

Parameters​

offset​

number

The zero-based start index.

limit​

number

The maximum number of products to return.

productFilters?​

MetafieldFilter[]

Optional product metafields to filter the products by.

tags?​

ProductTagFilter

Optional object of tag filters to apply.

sortKey?​

ProductCollectionProductSortKey

Optional field of the products to sort by.

sortDescending?​

boolean

Optional boolean to indicate if the sort should be in descending order.

quickSearch?​

string

Optional string to filter products by name.

workflowFilters?​

MetafieldFilter[]

Optional workflow metafields to filter the products and their workflows by.

Returns​

Promise<{ items: CollectionProduct[]; total: number; }>


getDescription()​

getDescription(): string

The description of the collection.

Returns​

string


getDispatchEndDate()​

getDispatchEndDate(): Date | undefined

The end date of the dispatch.

Returns​

Date | undefined

The end date of the dispatch or undefined if not set.


getDispatchStartDate()​

getDispatchStartDate(): Date | undefined

The start date of the dispatch.

Returns​

Date | undefined

The start date of the dispatch or undefined if not set.


getId()​

getId(): string

The ID of the product collection.

Returns​

string


getImage()​

getImage(): Asset | undefined

The image of the collection.

Returns​

Asset | undefined


getName()​

getName(): string

The name of the collection.

Returns​

string


getProducts()​

getProducts(): CollectionProduct[]

A list of products in this collections with useful helpers for interacting with them.

Returns​

CollectionProduct[]


getResource()​

getResource(): ProductCollectionResource

The raw collection resource. This is generally not needed and should be avoided.

Returns​

ProductCollectionResource