Search.../

addProductsToCollection( )

Adds products to a specified collection.

Admin Method

This function requires elevated permissions to run. This function is not universal and runs only on the backend.

Syntax

function addProductsToCollection(_id: string, productIds: Array<string>): Promise<void>

addProductsToCollection Parameters

NAME
TYPE
DESCRIPTION
_id
string

Collection ID.

productIds
Array<
string
>

IDs of the products to add to the collection, separated by commas.

Returns

Return Type:

Promise<
void
>

Was this helpful?

addProductsToCollection example

Copy Code
1import { products } from 'wix-stores.v2';
2
3 async function addProductsToCollection(id, productIds) {
4 try {
5 const result = await products.addProductsToCollection(id, productIds);
6
7 return result;
8 } catch (error) {
9 console.error(error);
10 // Handle the error
11 }
12 }
13