fix(medusa-plugin-brightpearl): only update inventory levels that are out of sync

This commit is contained in:
Sebastian Rindom
2020-08-27 09:52:28 +02:00
parent 0cebcd2521
commit db205bf790

View File

@@ -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,
})
}
})
)
}