diff --git a/packages/medusa-plugin-brightpearl/src/services/brightpearl.js b/packages/medusa-plugin-brightpearl/src/services/brightpearl.js index a114000e52..2fd27359e8 100644 --- a/packages/medusa-plugin-brightpearl/src/services/brightpearl.js +++ b/packages/medusa-plugin-brightpearl/src/services/brightpearl.js @@ -5,6 +5,7 @@ import Brightpearl from "../utils/brightpearl" class BrightpearlService extends BaseService { constructor( { + manager, oauthService, totalsService, productVariantService, @@ -18,6 +19,7 @@ class BrightpearlService extends BaseService { ) { super() + this.manager_ = manager this.options = options this.productVariantService_ = productVariantService this.regionService_ = regionService @@ -189,8 +191,12 @@ class BrightpearlService extends BaseService { .retrieveBySKU(sku) .catch((_) => undefined) if (variant && variant.manage_inventory) { - await this.productVariantService_.update(variant.id, { - inventory_quantity: onHand, + await this.manager_.transaction((m) => { + return this.productVariantService_ + .withTransaction(m) + .update(variant.id, { + inventory_quantity: onHand, + }) }) } }