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.
This commit is contained in:
Fabien O'Carroll 2021-06-23 10:19:10 +01:00
parent 1de88f7397
commit c46542532d

View File

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