Browse Source

Revert "fix: correct name and categories extraction in shoprenter-sync database cache #112"

This reverts commit d05251e5fd6ed263a1febc987226afb4bb0c2131.
Claude 4 months ago
parent
commit
e5e2500fed
1 changed files with 10 additions and 25 deletions
  1. 10 25
      supabase/functions/shoprenter-sync/index.ts

+ 10 - 25
supabase/functions/shoprenter-sync/index.ts

@@ -941,31 +941,16 @@ serve(wrapHandler('shoprenter-sync', async (req) => {
             // Collect all products for Qdrant sync
             allProducts.push(...productsData.items)
 
-            const productsToCache = productsData.items.map((product: any) => {
-              // Extract first language description from productDescriptions array
-              const productDesc = product.productDescriptions?.[0] || {}
-
-              // Extract category IDs from productCategoryRelations
-              const categoryIds: string[] = []
-              const categoryRelations = product.productCategoryRelations || []
-              for (const rel of categoryRelations) {
-                const categoryId = extractCategoryId(rel.category?.href)
-                if (categoryId) {
-                  categoryIds.push(categoryId)
-                }
-              }
-
-              return {
-                store_id: storeId,
-                product_id: product.id,
-                inner_id: product.innerId,
-                name: productDesc.name || product.name || null,
-                sku: product.sku || null,
-                categories: categoryIds,
-                excluded: false, // Will be set if in exclusion list
-                last_synced_at: new Date().toISOString()
-              }
-            })
+            const productsToCache = productsData.items.map((product: any) => ({
+              store_id: storeId,
+              product_id: product.id,
+              inner_id: product.innerId,
+              name: product.name,
+              sku: product.sku,
+              categories: product.productCategory || [],
+              excluded: false, // Will be set if in exclusion list
+              last_synced_at: new Date().toISOString()
+            }))
 
             const { error: upsertError } = await supabaseAdmin
               .from('shoprenter_products_cache')