fix(medusa-plugin-contentful): Fixes Medusa Contentful plugin

This commit is contained in:
Oliver Windall Juhl
2020-11-17 07:43:54 +01:00
committed by GitHub
parent f81eaa79b2
commit 34d3014db0
@@ -94,6 +94,9 @@ class ContentfulService extends BaseService {
variants: { variants: {
"en-US": variantLinks, "en-US": variantLinks,
}, },
options: {
"en-US": product.options,
},
objectId: { objectId: {
"en-US": product._id, "en-US": product._id,
}, },
@@ -127,6 +130,9 @@ class ContentfulService extends BaseService {
prices: { prices: {
"en-US": variant.prices, "en-US": variant.prices,
}, },
options: {
"en-US": variant.options,
},
objectId: { objectId: {
"en-US": variant._id, "en-US": variant._id,
}, },
@@ -267,15 +273,23 @@ class ContentfulService extends BaseService {
this.redis_.set("product_ignore_ids", JSON.stringify(ignoreIds)) this.redis_.set("product_ignore_ids", JSON.stringify(ignoreIds))
} }
// Get the thumbnail let update = {
const thumb = await environment.getAsset(
productEntry.fields.thumbnail["en-US"].sys.id
)
const updatedProduct = await this.productService_.update(productId, {
title: productEntry.fields.title["en-US"], 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 return updatedProduct
} catch (error) { } catch (error) {