diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/pages/api/magento-product.ts | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/pages/api/magento-product.ts b/src/pages/api/magento-product.ts index 297f0ebc..4e963844 100644 --- a/src/pages/api/magento-product.ts +++ b/src/pages/api/magento-product.ts @@ -103,6 +103,21 @@ export default async function handler( matrix.push(row); }); + // Deskripsi produk per varian + const descriptions:Record<string, string> = {}; + items.forEach((p: any) => { + const descAttr = p.custom_attributes.find((a: any) => a.attribute_code === 'description' || a.attribute_code === 'short_description'); + descriptions[p.sku] = descAttr ? descAttr.value : ''; + }); + + const warranties: Record<string, string> = {}; + items.forEach((p: any) => { + const warAttr = p.custom_attributes.find((a: any) => a.attribute_code === 'z_warranty'); + warranties[p.sku] = warAttr ? warAttr.value : ''; + }); + + + // ===================================================================== // 3. AMBIL LINKS (UPSELL & RELATED) DARI MAIN VARIANT SAJA // ===================================================================== @@ -126,7 +141,9 @@ export default async function handler( res.status(200).json({ specsMatrix: matrix, upsell_ids: upsellIds, - related_ids: relatedIds + related_ids: relatedIds, + descriptions: descriptions, + warranties: warranties, }); } catch (error) { |
