From c46542532dcf057e900be51ab3f0de3a5659767e Mon Sep 17 00:00:00 2001 From: Fabien O'Carroll Date: Wed, 23 Jun 2021 10:19:10 +0100 Subject: [PATCH] Added support for importing `products` column refs https://github.com/TryGhost/Team/issues/765 This supercedes the `complimentary_plan` flag, as it is more precise because it determines _which_ product(s) a member has access to. Because of this, if the `products` column is present the `complimentary_plan` column is not used. --- core/server/services/members/importer/importer.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/core/server/services/members/importer/importer.js b/core/server/services/members/importer/importer.js index c0089d5589..84d9ae3f32 100644 --- a/core/server/services/members/importer/importer.js +++ b/core/server/services/members/importer/importer.js @@ -150,7 +150,7 @@ module.exports = class MembersCSVImporter { } else if (row.complimentary_plan) { if (!labsService.isSet('multipleProducts')) { await membersApi.members.setComplimentarySubscription(member, options); - } else { + } else if (!row.products) { await membersApi.members.update({ products: [{id: defaultProduct.id}] }, { @@ -160,6 +160,17 @@ module.exports = class MembersCSVImporter { } } + if (labsService.isSet('multipleProducts')) { + if (row.products) { + await membersApi.members.update({ + products: row.products + }, { + ...options, + id: member.id + }); + } + } + await trx.commit(); return { ...resultAccumulator,