Merge remote-tracking branch 'origin/master' into develop

This commit is contained in:
Sebastian Rindom committed 2021-10-26 22:12:46 +02:00
commit b7eae378f9
10 files changed
+61 -12

No files matched your search

@@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.1.32](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.1.31...medusa-plugin-contentful@1.1.32) (2021-10-25)
### Bug Fixes
- make contentful data sync ([548f6c7](https://github.com/medusajs/medusa/commit/548f6c7138d9a08b6c2113ebdda27f13dee848ac))
## [1.1.31](https://github.com/medusajs/medusa/compare/medusa-plugin-contentful@1.1.30...medusa-plugin-contentful@1.1.31) (2021-10-18)
**Note:** Version bump only for package medusa-plugin-contentful
@@ -1,6 +1,6 @@
{
"name": "medusa-plugin-contentful",
"version": "1.1.31",
"version": "1.1.32",
"description": "Contentful plugin for Medusa Commerce",
"main": "index.js",
"repository": {
@@ -742,21 +742,35 @@ class ContentfulService extends BaseService {
const environment = await this.getContentfulEnvironment_()
const productEntry = await environment.getEntry(productId)
const product = await this.productService_.retrieve(productId)
const product = await this.productService_.retrieve(productId, {
select: [
"id",
"handle",
"title",
"subtitle",
"description",
"thumbnail",
],
})
const update = {}
const title =
productEntry.fields[this.getCustomField("title", "product")]["en-US"]
productEntry.fields[this.getCustomField("title", "product")]?.["en-US"]
const subtitle =
productEntry.fields[this.getCustomField("subtitle", "product")]["en-US"]
const description =
productEntry.fields[this.getCustomField("description", "product")][
productEntry.fields[this.getCustomField("subtitle", "product")]?.[
"en-US"
]
const description =
productEntry.fields[this.getCustomField("description", "product")]?.[
"en-US"
]
const handle =
productEntry.fields[this.getCustomField("handle", "product")]?.["en-US"]
if (product.title !== title) {
update.title = title
}
@@ -769,6 +783,10 @@ class ContentfulService extends BaseService {
update.description = description
}
if (product.handle !== handle) {
update.handle = handle
}
// Get the thumbnail, if present
if (productEntry.fields.thumbnail) {
const thumb = await environment.getAsset(
@@ -776,7 +794,7 @@ class ContentfulService extends BaseService {
)
if (thumb.fields.file["en-US"].url) {
if (!product.thumbnail.includes(thumb.fields.file["en-US"].url)) {
if (!product.thumbnail?.includes(thumb.fields.file["en-US"].url)) {
update.thumbnail = thumb.fields.file["en-US"].url
}
}
@@ -834,7 +852,6 @@ class ContentfulService extends BaseService {
output.push(transformed)
}
console.log(output)
if (!isArray) {
return output[0]
}