Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export const MIGRATION_DATA_CONFIG = {
CATEGORIES_FILE_NAME: "en-us.json",
CATEGORIES_MASTER_FILE: "categories.json",

TAG_DIR_NAME: "tags",
TAG_DIR_NAME: "tag",
TAG_FILE_NAME: "en-us.json",
TAG_MASTER_FILE: "tag.json",

Expand Down
2 changes: 1 addition & 1 deletion api/src/services/contentMapper.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ const resetToInitialMapping = async (req: Request) => {
[
NEW_PROJECT_STATUS[0],
NEW_PROJECT_STATUS[5],
NEW_PROJECT_STATUS[4],
//NEW_PROJECT_STATUS[4],
].includes(project.status) ||
project.current_step < STEPPER_STEPS.CONTENT_MAPPING
) {
Expand Down
24 changes: 16 additions & 8 deletions api/src/services/wordpress.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,7 @@ async function saveAuthors(authorDetails: any[], destinationStackId: string, pro
uid: customId,
...mapContentTypeToEntry(contentType, authordata),
};
acc[customId].publish_details = [];


return acc;
Expand Down Expand Up @@ -1463,7 +1464,7 @@ async function saveTerms(termsDetails: any[], destinationStackId: string, projec
uid: customId,
...mapContentTypeToEntry(contentType, data), // Pass individual term object
};

acc[customId].publish_details = [];
return acc;
},
{}
Expand Down Expand Up @@ -1587,6 +1588,7 @@ async function saveTags(tagDetails: any[], destinationStackId: string, projectId
uid:customId,
...mapContentTypeToEntry(contenttype,data),
};
acc[customId].publish_details = [];

return acc;
}, {});
Expand Down Expand Up @@ -1729,6 +1731,7 @@ async function saveCategories(categoryDetails: any[], destinationStackId:string,
uid:customId,
...mapContentTypeToEntry(contenttype,data),
}
acc[customId].publish_details = [];

return acc;
},
Expand Down Expand Up @@ -1873,10 +1876,13 @@ const limit = limitConcurrency(5);

async function featuredImageMapping(postid: string, post: any, postdata: any) {
try {

const assetsId = JSON.parse(fs.readFileSync(
path.join(process.cwd(), assetsSave, MIGRATION_DATA_CONFIG.ASSETS_SCHEMA_FILE),'utf8'
));
const filePath = path.join(process.cwd(), assetsSave, MIGRATION_DATA_CONFIG.ASSETS_SCHEMA_FILE);
const fileContent = fs.readFileSync(filePath, 'utf8').trim();

if (!fileContent) {
throw new Error(`File ${filePath} is empty or missing`);
}
const assetsId = JSON?.parse(fileContent);
if (!post["wp:postmeta"] || !assetsId) return;

const postmetaArray = Array.isArray(post["wp:postmeta"]) ? post["wp:postmeta"]
Expand Down Expand Up @@ -2018,14 +2024,15 @@ async function processChunkData(
category: postCategories,
terms: postTerms,
tag: postTags,
featured_image: ''
featured_image: '',
publish_details:[]
};
const formatted_posts = await featuredImageMapping(
`posts_${data["wp:post_id"]}`,
data,
postdata
);
const formattedPosts = Object.entries(formatted_posts).reduce(
const formattedPosts = Object?.entries(formatted_posts)?.reduce(
(acc: { [key: string]: any }, data:any) => {

const customId = idCorrector(data["uid"])
Expand All @@ -2035,7 +2042,8 @@ async function processChunkData(
...acc[customId],
uid: customId,
...mapContentTypeToEntry(contenttype,data),
}
};
acc[customId].publish_details = [];

return acc;
},
Expand Down
27 changes: 18 additions & 9 deletions upload-api/migration-wordpress/libs/contenttypemapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ const ContentTypeSchema = ({
contentstackField: name.toLowerCase(),
contentstackFieldUid: uid,
contentstackFieldType: 'text',
backupFieldType: 'text'
backupFieldType: 'text',
backupFieldUid: uid
};
}
if (sitecoreKey === 'url') {
Expand All @@ -80,7 +81,8 @@ const ContentTypeSchema = ({
contentstackField: name.toLowerCase(),
contentstackFieldUid: uid,
contentstackFieldType: 'url',
backupFieldType: 'url'
backupFieldType: 'url',
backupFieldUid: uid
};
}
switch (type) {
Expand All @@ -94,7 +96,8 @@ const ContentTypeSchema = ({
contentstackFieldUid: uid,
contentstackFieldType: 'single_line_text',
backupFieldType: 'single_line_text',
advanced: { default_value: default_value !== '' ? default_value : null }
advanced: { default_value: default_value !== '' ? default_value : null },
backupFieldUid: uid
};
}

Expand All @@ -109,7 +112,8 @@ const ContentTypeSchema = ({
contentstackFieldUid: uid,
contentstackFieldType: 'json',
backupFieldType: 'json',
advanced: { default_value: default_value !== '' ? default_value : null }
advanced: { default_value: default_value !== '' ? default_value : null },
backupFieldUid: uid
};
}

Expand All @@ -124,7 +128,8 @@ const ContentTypeSchema = ({
contentstackFieldUid: uid,
contentstackFieldType: 'file',
backupFieldType: 'file',
advanced: { default_value: default_value !== '' ? default_value : null }
advanced: { default_value: default_value !== '' ? default_value : null },
backupFieldUid: uid
};
}

Expand All @@ -138,7 +143,8 @@ const ContentTypeSchema = ({
contentstackFieldUid: uid,
contentstackFieldType: 'multi_line_text',
backupFieldType: 'multi_line_text',
advanced: { default_value: default_value !== '' ? default_value : null }
advanced: { default_value: default_value !== '' ? default_value : null },
backupFieldUid: uid
};
}

Expand All @@ -153,7 +159,8 @@ const ContentTypeSchema = ({
contentstackFieldUid: uid,
contentstackFieldType: 'number',
backupFieldType: 'number',
advanced: { default_value: default_value !== '' ? default_value : null }
advanced: { default_value: default_value !== '' ? default_value : null },
backupFieldUid: uid
};
}

Expand All @@ -169,7 +176,8 @@ const ContentTypeSchema = ({
contentstackFieldUid: uid,
contentstackFieldType: 'isodate',
backupFieldType: 'isodate',
advanced: { default_value: default_value !== '' ? default_value : null }
advanced: { default_value: default_value !== '' ? default_value : null },
backupFieldUid: uid
};
}

Expand All @@ -183,7 +191,8 @@ const ContentTypeSchema = ({
contentstackFieldUid: uid,
contentstackFieldType: 'reference',
backupFieldType: 'reference',
refrenceTo: reference_to
refrenceTo: reference_to,
backupFieldUid: uid
};
}
}
Expand Down