Search.../

bulkUpdateProductProperty( )

Updates a property for up to 100 products at a time.

Description

The bulkUpdateProductProperty() function returns a Promise that resolves when the property of the products have been updated.

The properties that can be bulk-updated are detailed in the set object in the parameters section below.

Note: Do not pass important information from client-side code. Doing so opens a vulnerability that a malicious user can exploit to change information, such as a buyer’s personal details (address, email, etc.) or product price information. To learn more about how to keep your code secure, see Security Considerations When Working with Wix Code.

Authorization

Request

This endpoint does not take any parameters

Response Object

Fulfilled - Bulk action results and metadata. Rejected - Error message.

NAME
TYPE
DESCRIPTION
results
Array<BulkResults>

Bulk action results.

bulkActionMetadata
BulkActionMetadata

Bulk action metadata.

Status/Error Codes

Was this helpful?

Update the price of multiple products

Copy Code
1/**************************************
2 * Backend code - my-backend-file.jsw *
3 **************************************/
4
5import wixStoresBackend from 'wix-stores-backend';
6
7export async function myBulkUpdateProductPropertyFunction(ids, set) {
8 try {
9 const productUpdateResults = await wixStoresBackend.bulkUpdateProductProperty(ids, set);
10 console.log('Bulk action results:', productUpdateResults);
11 return productUpdateResults;
12 } catch (error) {
13 console.error(error);
14 // Handle the error
15 }
16}
17
18/*************
19 * Page code *
20 *************/
21
22import { myBulkUpdateProductPropertyFunction } from 'backend/my-backend-file';
23
24// Sample product IDs:
25const ids = [
26 "bb6ddd51-7295-4fc8-8a4f-2521485c738d",
27 "c36bbdbe-fbf8-4a43-810e-a0abdffe70ae",
28 "2966543c-2b2f-4ca1-862c-6a04736c1063",
29 "c9adb138-96f8-4f08-8626-9fef2445c490",
30 "4ed1aa2c-c441-4e3f-8e57-a18886bf52bb"
31]
32
33// Set the price to 10.25
34const set = {
35 "price": 10.25
36}
37
38myBulkUpdateProductPropertyFunction(ids, set)
39 .then((productUpdateResults) => {
40 console.log('Bulk action results:', productUpdateResults);
41 return productUpdateResults;
42 })
43 .catch((error) => {
44 console.error(error);
45 // Handle the error
46 });
47
48/* Promise resolves to:
49 *
50 * {
51 * "results": [
52 * {"itemMetadata": {
53 * "id": "bb6ddd51-7295-4fc8-8a4f-2521485c738d",
54 * "originalIndex": 0,
55 * "success": true
56 * }},
57 * {"itemMetadata": {
58 * "id": "c36bbdbe-fbf8-4a43-810e-a0abdffe70ae",
59 * "originalIndex": 1,
60 * "success": true
61 * }},
62 * {"itemMetadata": {
63 * "id": "2966543c-2b2f-4ca1-862c-6a04736c1063",
64 * "originalIndex": 2,
65 * "success": true
66 * }},
67 * {"itemMetadata": {
68 * "id": "c9adb138-96f8-4f08-8626-9fef2445c490",
69 * "originalIndex": 3,
70 * "success": true
71 * }},
72 * {"itemMetadata": {
73 * "id": "4ed1aa2c-c441-4e3f-8e57-a18886bf52bb",
74 * "originalIndex": 4,
75 * "success": true
76 * }}
77 * ],
78 * "bulkActionMetadata": {
79 * "totalSuccesses": 5,
80 * "totalFailures": 0,
81 * "undetailedFailures": 0
82 * }
83 * }
84 *
85 */
Update the ribbon property of multiple products

Copy Code
1/**************************************
2 * Backend code - my-backend-file.jsw *
3 **************************************/
4
5import wixStoresBackend from 'wix-stores-backend';
6
7export async function myBulkUpdateProductPropertyFunction(ids, set) {
8 try {
9 const productUpdateResults = await wixStoresBackend.bulkUpdateProductProperty(ids, set);
10 console.log('Bulk action results:', productUpdateResults);
11 return productUpdateResults;
12 } catch (error) {
13 console.error(error);
14 // Handle the error
15 }
16}
17
18/*************
19 * Page code *
20 *************/
21
22import { myBulkUpdateProductPropertyFunction } from 'backend/my-backend-file';
23
24// Sample product IDs:
25const ids = [
26 "bb6ddd51-7295-4fc8-8a4f-2521485c738d",
27 "c36bbdbe-fbf8-4a43-810e-a0abdffe70ae",
28 "2966543c-2b2f-4ca1-862c-6a04736c1063"
29]
30
31// Set the ribbon to "On Sale"
32const set = {
33 "ribbon": "On Sale"
34}
35
36myBulkUpdateProductPropertyFunction(ids, set)
37 .then((productUpdateResults) => {
38 console.log('Bulk action results:', productUpdateResults);
39 return productUpdateResults;
40 })
41 .catch((error) => {
42 console.error(error);
43 // Handle the error
44 });
45
46/* Promise resolves to:
47 *
48 * {
49 * "results": [
50 * {"itemMetadata": {
51 * "id": "bb6ddd51-7295-4fc8-8a4f-2521485c738d",
52 * "originalIndex": 0,
53 * "success": true
54 * }},
55 * {"itemMetadata": {
56 * "id": "c36bbdbe-fbf8-4a43-810e-a0abdffe70ae",
57 * "originalIndex": 1,
58 * "success": true
59 * }},
60 * {"itemMetadata": {
61 * "id": "2966543c-2b2f-4ca1-862c-6a04736c1063",
62 * "originalIndex": 2,
63 * "success": true
64 * }}
65 * ],
66 * "bulkActionMetadata": {
67 * "totalSuccesses": 3,
68 * "totalFailures": 0,
69 * "undetailedFailures": 0
70 * }
71 * }
72 *
73 */
Attempt to update the weight of multiple products

In this example, the second product ID is not found, so an error is returned for that update action.

Copy Code
1/**************************************
2 * Backend code - my-backend-file.jsw *
3 **************************************/
4
5import wixStoresBackend from 'wix-stores-backend';
6
7export async function myBulkUpdateProductPropertyFunction(ids, set) {
8 try {
9 const productUpdateResults = await wixStoresBackend.bulkUpdateProductProperty(ids, set);
10 console.log('Bulk action results:', productUpdateResults);
11 return productUpdateResults;
12 } catch (error) {
13 console.error(error);
14 // Handle the error
15 }
16}
17
18/*************
19 * Page code *
20 *************/
21
22import { myBulkUpdateProductPropertyFunction } from 'backend/my-backend-file';
23
24// Sample product IDs:
25const ids = [
26 "bb6ddd51-7295-4fc8-8a4f-2521485c738d",
27 "4deb9c8d-7aba-45e1-9d83-bf99b479b5bb"
28]
29
30// Set the weight to 2.64
31const set = {
32 "weight": "2.64"
33}
34
35myBulkUpdateProductPropertyFunction(ids, set)
36 .then((productUpdateResults) => {
37 console.log('Bulk action results:', productUpdateResults);
38 return productUpdateResults;
39 })
40 .catch((error) => {
41 console.error(error);
42 // Handle the error
43 });
44
45/* Promise resolves to:
46 *
47 * {
48 * "results": [
49 * {"itemMetadata": {
50 * "id": "bb6ddd51-7295-4fc8-8a4f-2521485c738d",
51 * "originalIndex": 0,
52 * "success": true
53 * }},
54 * {"itemMetadata": {
55 * "id": "4deb9c8d-7aba-45e1-9d83-bf99b479b5bb",
56 * "originalIndex": 1,
57 * "success": false,
58 * "error": {
59 * "code": "PRODUCT_NOT_FOUND",
60 * "description": "Product is not found"
61 * }
62 * }}
63 * ],
64 * "bulkActionMetadata": {
65 * "totalSuccesses": 1,
66 * "totalFailures": 1,
67 * "undetailedFailures": 0
68 * }
69 * }
70 *
71 */
72