From 237ed5130760645c6b892fa1d5fc09a713b95f58 Mon Sep 17 00:00:00 2001 From: Sebastian Rindom Date: Fri, 9 Apr 2021 19:31:56 +0200 Subject: [PATCH] fix: restock --- .../src/services/restock-notification.js | 1 + .../medusa-plugin-sendgrid/src/services/sendgrid.js | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/medusa-plugin-restock-notification/src/services/restock-notification.js b/packages/medusa-plugin-restock-notification/src/services/restock-notification.js index 12b7c3b56c..34a835a5cb 100644 --- a/packages/medusa-plugin-restock-notification/src/services/restock-notification.js +++ b/packages/medusa-plugin-restock-notification/src/services/restock-notification.js @@ -39,6 +39,7 @@ class RestockNotificationService extends BaseService { options: this.options_, eventBusService: this.eventBus_, productVariantService: this.productVariantService_, + restockNotificationModel: this.restockNotificationModel_, }) cloned.transactionManager_ = transactionManager diff --git a/packages/medusa-plugin-sendgrid/src/services/sendgrid.js b/packages/medusa-plugin-sendgrid/src/services/sendgrid.js index c169c0fe2d..df16920005 100644 --- a/packages/medusa-plugin-sendgrid/src/services/sendgrid.js +++ b/packages/medusa-plugin-sendgrid/src/services/sendgrid.js @@ -30,6 +30,7 @@ class SendGridService extends NotificationService { fulfillmentService, fulfillmentProviderService, totalsService, + productVariantService, }, options ) { @@ -46,6 +47,7 @@ class SendGridService extends NotificationService { this.swapService_ = swapService this.fulfillmentService_ = fulfillmentService this.totalsService_ = totalsService + this.productVariantService_ = productVariantService SendGrid.setApiKey(options.api_key) } @@ -122,7 +124,10 @@ class SendGridService extends NotificationService { case "customer.password_reset": return this.customerPasswordResetData(eventData, attachmentGenerator) case "restock-notification.restocked": - return await this.restockNotificationData(eventData, attachmentGenerator) + return await this.restockNotificationData( + eventData, + attachmentGenerator + ) default: return {} } @@ -677,14 +682,14 @@ class SendGridService extends NotificationService { async restockNotificationData({ variant_id, emails }) { const variant = await this.productVariantService_.retrieve(variant_id, { - relations: ["product"] + relations: ["product"], }) return { product: variant.product, variant, variant_id, - emails + emails, } }