From a2ef25734e8b8e0d039caf5af1d6ce16fbb92719 Mon Sep 17 00:00:00 2001 From: Sebastian Rindom Date: Thu, 25 Mar 2021 16:56:08 +0100 Subject: [PATCH] hotfix(bp): only sync from select warehouse --- .../src/services/brightpearl.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/medusa-plugin-brightpearl/src/services/brightpearl.js b/packages/medusa-plugin-brightpearl/src/services/brightpearl.js index 88a50fe54b..c9616fe93b 100644 --- a/packages/medusa-plugin-brightpearl/src/services/brightpearl.js +++ b/packages/medusa-plugin-brightpearl/src/services/brightpearl.js @@ -182,7 +182,16 @@ class BrightpearlService extends BaseService { if (availability) { const brightpearlProduct = await client.products.retrieve(productId) - const onHand = availability[productId].total.onHand + + const prodAvail = availability[productId] + + let onHand = 0 + if ( + prodAvail.warehouses && + prodAvail.warehouses[`${this.options.warehouse}`] + ) { + onHand = prodAvail.warehouses[`${this.options.warehouse}`].onHand + } const sku = brightpearlProduct.identity.sku if (!sku) return