From 34d3014db0f1d6be3df0e2ff4b5ca11c505b245d Mon Sep 17 00:00:00 2001 From: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com> Date: Tue, 17 Nov 2020 07:43:54 +0100 Subject: [PATCH] fix(medusa-plugin-contentful): Fixes Medusa Contentful plugin --- .../src/services/contentful.js | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/packages/medusa-plugin-contentful/src/services/contentful.js b/packages/medusa-plugin-contentful/src/services/contentful.js index cc4282f6c4..750d2a1cfd 100644 --- a/packages/medusa-plugin-contentful/src/services/contentful.js +++ b/packages/medusa-plugin-contentful/src/services/contentful.js @@ -94,6 +94,9 @@ class ContentfulService extends BaseService { variants: { "en-US": variantLinks, }, + options: { + "en-US": product.options, + }, objectId: { "en-US": product._id, }, @@ -127,6 +130,9 @@ class ContentfulService extends BaseService { prices: { "en-US": variant.prices, }, + options: { + "en-US": variant.options, + }, objectId: { "en-US": variant._id, }, @@ -267,15 +273,23 @@ class ContentfulService extends BaseService { this.redis_.set("product_ignore_ids", JSON.stringify(ignoreIds)) } - // Get the thumbnail - const thumb = await environment.getAsset( - productEntry.fields.thumbnail["en-US"].sys.id - ) - - const updatedProduct = await this.productService_.update(productId, { + let update = { title: productEntry.fields.title["en-US"], - thumbnail: thumb.fields.file["en-US"].url, - }) + } + + // Get the thumbnail, if present + if (productEntry.fields.thumbnail) { + const thumb = await environment.getAsset( + productEntry.fields.thumbnail["en-US"].sys.id + ) + + update.thumbnail = thumb.fields.file["en-US"].url + } + + const updatedProduct = await this.productService_.update( + productId, + update + ) return updatedProduct } catch (error) {