|
@@ -183,15 +183,19 @@ serve(wrapHandler('shoprenter-scheduled-sync', async (req) => {
|
|
|
if (productsData.items && productsData.items.length > 0) {
|
|
if (productsData.items && productsData.items.length > 0) {
|
|
|
const productsToCache = productsData.items.map((product: any) => ({
|
|
const productsToCache = productsData.items.map((product: any) => ({
|
|
|
store_id: storeId,
|
|
store_id: storeId,
|
|
|
- shoprenter_product_id: product.id,
|
|
|
|
|
- product_data: product,
|
|
|
|
|
|
|
+ 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()
|
|
last_synced_at: new Date().toISOString()
|
|
|
}))
|
|
}))
|
|
|
|
|
|
|
|
const { error: upsertError } = await supabaseAdmin
|
|
const { error: upsertError } = await supabaseAdmin
|
|
|
.from('shoprenter_products_cache')
|
|
.from('shoprenter_products_cache')
|
|
|
.upsert(productsToCache, {
|
|
.upsert(productsToCache, {
|
|
|
- onConflict: 'store_id,shoprenter_product_id'
|
|
|
|
|
|
|
+ onConflict: 'store_id,product_id'
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
if (upsertError) {
|
|
if (upsertError) {
|