From db205bf79024bc54f6bc73a90ea7427f65c642be Mon Sep 17 00:00:00 2001 From: Sebastian Rindom Date: Thu, 27 Aug 2020 09:52:28 +0200 Subject: [PATCH] fix(medusa-plugin-brightpearl): only update inventory levels that are out of sync --- .../src/services/brightpearl.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/medusa-plugin-brightpearl/src/services/brightpearl.js b/packages/medusa-plugin-brightpearl/src/services/brightpearl.js index df7f545a43..95cee6bc2e 100644 --- a/packages/medusa-plugin-brightpearl/src/services/brightpearl.js +++ b/packages/medusa-plugin-brightpearl/src/services/brightpearl.js @@ -138,9 +138,12 @@ class BrightpearlService extends BaseService { ) const onHand = availability[productId].total.onHand - return this.productVariantService_.update(v._id, { - inventory_quantity: onHand, - }) + // Only update if the inventory levels have changed + if (parseInt(v.inventory_quantity) !== parseInt(onHand)) { + return this.productVariantService_.update(v._id, { + inventory_quantity: onHand, + }) + } }) ) }