Updates a property for up to 100 products at a time.
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.
function bulkUpdateProductProperty(
ids: Array<string>,
set: BulkUpdateProperties,
): Promise<BulkUpdateResponse>;
IDs of the products to update.
Property to update.
/**************************************
* Backend code - my-backend-file.jsw *
**************************************/
import wixStoresBackend from "wix-stores-backend";
export async function myBulkUpdateProductPropertyFunction(ids, set) {
try {
const productUpdateResults =
await wixStoresBackend.bulkUpdateProductProperty(ids, set);
console.log("Bulk action results:", productUpdateResults);
return productUpdateResults;
} catch (error) {
console.error(error);
// Handle the error
}
}
/*************
* Page code *
*************/
import { myBulkUpdateProductPropertyFunction } from "backend/my-backend-file";
// Sample product IDs:
const ids = [
"bb6ddd51-7295-4fc8-8a4f-2521485c738d",
"c36bbdbe-fbf8-4a43-810e-a0abdffe70ae",
"2966543c-2b2f-4ca1-862c-6a04736c1063",
"c9adb138-96f8-4f08-8626-9fef2445c490",
"4ed1aa2c-c441-4e3f-8e57-a18886bf52bb",
];
// Set the price to 10.25
const set = {
price: 10.25,
};
myBulkUpdateProductPropertyFunction(ids, set)
.then((productUpdateResults) => {
console.log("Bulk action results:", productUpdateResults);
return productUpdateResults;
})
.catch((error) => {
console.error(error);
// Handle the error
});
/* Promise resolves to:
*
* {
* "results": [
* {"itemMetadata": {
* "id": "bb6ddd51-7295-4fc8-8a4f-2521485c738d",
* "originalIndex": 0,
* "success": true
* }},
* {"itemMetadata": {
* "id": "c36bbdbe-fbf8-4a43-810e-a0abdffe70ae",
* "originalIndex": 1,
* "success": true
* }},
* {"itemMetadata": {
* "id": "2966543c-2b2f-4ca1-862c-6a04736c1063",
* "originalIndex": 2,
* "success": true
* }},
* {"itemMetadata": {
* "id": "c9adb138-96f8-4f08-8626-9fef2445c490",
* "originalIndex": 3,
* "success": true
* }},
* {"itemMetadata": {
* "id": "4ed1aa2c-c441-4e3f-8e57-a18886bf52bb",
* "originalIndex": 4,
* "success": true
* }}
* ],
* "bulkActionMetadata": {
* "totalSuccesses": 5,
* "totalFailures": 0,
* "undetailedFailures": 0
* }
* }
*
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.