Add mass edit of visible, browsable and blacklisting (#86)

* Add massedit WIP

* Add massedit

* Review comments

* Remove more debug
This commit is contained in:
Niklas Fondberg
2021-12-03 11:48:10 +01:00
committed by GitHub
parent 8096e4730c
commit 8cea3b5db6
3 changed files with 80 additions and 0 deletions
+33
View File
@@ -463,6 +463,39 @@ export class ProductAPI extends BaseSQLDataSource {
return Promise.all(promises);
}
/**
* @function massUpdatePublishing
* @description Mass update visible and browsable
*/
async massUpdatePublishing(
productIds: Array<number>,
visible: boolean,
browsable: boolean,
) {
return this.knex
.table('product-products')
.update({
browsable: browsable ? 1 : 0,
visible: visible ? 1 : 0,
})
.whereIn('productid', productIds);
}
/**
* @function massUpdateBlacklisting
* @description Mass update blacklisting
*/
async massUpdateBlacklisting(
productIds: Array<number>,
markets: Array<ProductBlacklistMarketInput>,
) {
const promises = productIds.map((pId) =>
this.updateBlacklisting(pId, markets),
);
return Promise.all(promises);
}
/**
* @function updateFocusPoint
* @description Updates the focus point on a motif