From 6169c36ea2397c4cb48ec9a8881a3d5aad2ea139 Mon Sep 17 00:00:00 2001 From: AishDani Date: Thu, 5 Mar 2026 13:13:52 +0530 Subject: [PATCH 1/2] fix: improve category handling in WordPress service and update UI component logic for taxonomy loading and resolved bug --- api/src/services/wordpress.service.ts | 7 +++++-- ui/src/components/AdvancePropertise/index.tsx | 6 +++--- ui/src/components/ContentMapper/index.tsx | 3 ++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/api/src/services/wordpress.service.ts b/api/src/services/wordpress.service.ts index 293899b3..fa7044c6 100644 --- a/api/src/services/wordpress.service.ts +++ b/api/src/services/wordpress.service.ts @@ -586,6 +586,7 @@ async function createEntry(file_path: string, packagePath: string, destinationSt const entriesJsonData = JSON.parse(Jsondata); const entries = entriesJsonData?.rss?.channel?.["item"]; const categories = entriesJsonData?.rss?.channel?.["wp:category"]; + const allCategories = Array?.isArray(categories) ? categories : (categories ? [categories] : []); const authorsData = entriesJsonData?.rss?.channel?.["wp:author"]; const authors = Array?.isArray(authorsData) ? authorsData : [authorsData]; @@ -677,7 +678,7 @@ async function createEntry(file_path: string, packagePath: string, destinationSt // console.log(`No ${type} found to extract`); // } // } - const content = await saveEntry(contentType?.fieldMapping, entry,file_path, assetData, categories, master_locale, destinationStackId, project, allTerms) || {}; + const content = await saveEntry(contentType?.fieldMapping, entry,file_path, assetData, allCategories, master_locale, destinationStackId, project, allTerms) || {}; const filePath = path.join(postFolderPath, `${locale}.json`); await writeFileAsync(filePath, content, 4); @@ -696,7 +697,9 @@ async function createTaxonomy(file_path: string, packagePath: string, destinatio const Jsondata = await fs.promises.readFile(packagePath, "utf8"); const xmlData = await fs.promises.readFile(file_path, "utf8"); - const categoriesJsonData = JSON.parse(Jsondata)?.rss?.channel?.["wp:category"] || JSON.parse(Jsondata)?.channel?.["wp:category"] || []; + const categoriesData = JSON.parse(Jsondata)?.rss?.channel?.["wp:category"] || JSON.parse(Jsondata)?.channel?.["wp:category"]; + const categoriesJsonData = Array?.isArray(categoriesData) ? categoriesData : (categoriesData ? [categoriesData] : []); + if(categoriesJsonData?.length > 0){ const allTaxonomies : any = {} for(const category of categoriesJsonData){ diff --git a/ui/src/components/AdvancePropertise/index.tsx b/ui/src/components/AdvancePropertise/index.tsx index 605020e6..db3fb371 100644 --- a/ui/src/components/AdvancePropertise/index.tsx +++ b/ui/src/components/AdvancePropertise/index.tsx @@ -805,7 +805,7 @@ const AdvancePropertise = (props: SchemaProps) => {