|
| 1 | +# 📦 Bulk Upload Template Guide |
| 2 | + |
| 3 | +## 📋 File Templates yang Tersedia |
| 4 | + |
| 5 | +1. **bulk-upload-example.csv** - Template dengan 5 contoh produk lengkap |
| 6 | +2. **bulk-upload-template-blank.csv** - Template kosong untuk diisi manual |
| 7 | +3. **product-template.csv** - Template dasar |
| 8 | + |
| 9 | +## 📊 Format CSV |
| 10 | + |
| 11 | +### Header (Kolom yang Diperlukan) |
| 12 | + |
| 13 | +```csv |
| 14 | +title,price,manufacturer,inStock,mainImage,description,slug,categoryId |
| 15 | +``` |
| 16 | + |
| 17 | +### Deskripsi Kolom |
| 18 | + |
| 19 | +| Kolom | Wajib | Tipe | Deskripsi | Contoh | |
| 20 | +| ---------------- | -------- | ------ | ------------------------------------------------------ | --------------------------------- | |
| 21 | +| **title** | ✅ Ya | String | Nama produk | Samsung Galaxy S24 Ultra | |
| 22 | +| **price** | ✅ Ya | Number | Harga produk (gunakan titik untuk desimal) | 1299.99 | |
| 23 | +| **manufacturer** | ✅ Ya | String | Nama manufaktur/brand | Samsung | |
| 24 | +| **inStock** | ❌ Tidak | Number | Jumlah stok (default: 0) | 25 | |
| 25 | +| **mainImage** | ❌ Tidak | URL | URL gambar produk | https://example.com/image.jpg | |
| 26 | +| **description** | ✅ Ya | String | Deskripsi produk | The latest flagship smartphone... | |
| 27 | +| **slug** | ✅ Ya | String | URL-friendly identifier (gunakan huruf kecil dan dash) | samsung-galaxy-s24-ultra | |
| 28 | +| **categoryId** | ✅ Ya | String | ID kategori dari database (atau nama kategori) | electronics | |
| 29 | + |
| 30 | +## ⚠️ Aturan Penting |
| 31 | + |
| 32 | +### 1. Format Data |
| 33 | + |
| 34 | +- **Harga**: Gunakan titik (.) untuk desimal, bukan koma |
| 35 | + |
| 36 | + - ✅ Benar: `1299.99` |
| 37 | + - ❌ Salah: `1.299,99` |
| 38 | + |
| 39 | +- **Slug**: Harus URL-friendly (lowercase, no spaces) |
| 40 | + |
| 41 | + - ✅ Benar: `samsung-galaxy-s24` |
| 42 | + - ❌ Salah: `Samsung Galaxy S24` |
| 43 | + |
| 44 | +- **Text dengan Koma**: Gunakan tanda kutip ganda |
| 45 | + - ✅ Benar: `"Camera with 200MP, 50MP, and 12MP lenses"` |
| 46 | + - ❌ Salah: `Camera with 200MP, 50MP, and 12MP lenses` |
| 47 | + |
| 48 | +### 2. Category ID |
| 49 | + |
| 50 | +Anda bisa menggunakan: |
| 51 | + |
| 52 | +- **UUID kategori** dari database (rekomendasi) |
| 53 | +- **Nama kategori** (akan dicari di database) |
| 54 | + |
| 55 | +Untuk mendapatkan category ID yang valid: |
| 56 | + |
| 57 | +```javascript |
| 58 | +// Jalankan di server directory: |
| 59 | +node -e "const {PrismaClient} = require('@prisma/client'); const p = new PrismaClient(); p.category.findMany().then(c => {console.log(c); p.$disconnect()});" |
| 60 | +``` |
| 61 | + |
| 62 | +### 3. Image URL |
| 63 | + |
| 64 | +- Gunakan URL lengkap dengan `http://` atau `https://` |
| 65 | +- Rekomendasi: Unsplash, atau upload ke CDN terlebih dahulu |
| 66 | +- Jika kosong, akan menggunakan placeholder default |
| 67 | + |
| 68 | +## 📝 Contoh Row CSV |
| 69 | + |
| 70 | +### Format Basic |
| 71 | + |
| 72 | +```csv |
| 73 | +title,price,manufacturer,inStock,mainImage,description,slug,categoryId |
| 74 | +iPhone 15 Pro,999.99,Apple,50,https://example.com/iphone.jpg,Latest iPhone model,iphone-15-pro,smartphones |
| 75 | +``` |
| 76 | + |
| 77 | +### Format dengan Deskripsi Panjang |
| 78 | + |
| 79 | +```csv |
| 80 | +title,price,manufacturer,inStock,mainImage,description,slug,categoryId |
| 81 | +"Sony WH-1000XM5","399.99",Sony,30,https://example.com/sony.jpg,"Premium wireless headphones with industry-leading noise cancellation, 30-hour battery life, and exceptional sound quality.",sony-wh-1000xm5,audio |
| 82 | +``` |
| 83 | + |
| 84 | +## 🚀 Cara Upload |
| 85 | + |
| 86 | +### Via Admin Dashboard |
| 87 | + |
| 88 | +1. Login ke admin dashboard |
| 89 | +2. Buka menu **Bulk Upload** |
| 90 | +3. Download template CSV atau gunakan yang sudah ada |
| 91 | +4. Isi data produk sesuai format |
| 92 | +5. Drag & drop file CSV atau klik "Select CSV File" |
| 93 | +6. Klik "Upload Products" |
| 94 | +7. Tunggu proses selesai dan lihat hasilnya |
| 95 | + |
| 96 | +### Via API (Advanced) |
| 97 | + |
| 98 | +```bash |
| 99 | +curl -X POST http://localhost:3001/api/products/bulk-upload \ |
| 100 | + -F "file=@bulk-upload-example.csv" |
| 101 | +``` |
| 102 | + |
| 103 | +## ✅ Checklist Sebelum Upload |
| 104 | + |
| 105 | +- [ ] Semua kolom wajib sudah diisi (title, price, manufacturer, description, slug, categoryId) |
| 106 | +- [ ] Harga menggunakan format angka dengan titik untuk desimal |
| 107 | +- [ ] Slug unik dan URL-friendly (lowercase, dash-separated) |
| 108 | +- [ ] Category ID valid (ada di database) |
| 109 | +- [ ] Image URL valid (jika diisi) |
| 110 | +- [ ] Text dengan koma dibungkus tanda kutip ganda |
| 111 | +- [ ] File berformat CSV (bukan Excel .xlsx) |
| 112 | + |
| 113 | +## 🔍 Troubleshooting |
| 114 | + |
| 115 | +### Error: "Category not found" |
| 116 | + |
| 117 | +- Pastikan categoryId yang digunakan ada di database |
| 118 | +- Atau gunakan nama kategori yang sudah terdaftar |
| 119 | + |
| 120 | +### Error: "Duplicate slug" |
| 121 | + |
| 122 | +- Slug harus unik untuk setiap produk |
| 123 | +- Ubah slug menjadi lebih spesifik: `macbook-pro-16-2024` instead of `macbook` |
| 124 | + |
| 125 | +### Error: "Invalid price format" |
| 126 | + |
| 127 | +- Gunakan angka dengan titik untuk desimal |
| 128 | +- Jangan gunakan simbol mata uang (Rp, $, dll) |
| 129 | + |
| 130 | +### Error: "CSV parsing failed" |
| 131 | + |
| 132 | +- Pastikan format CSV benar |
| 133 | +- Gunakan text editor atau Excel untuk edit |
| 134 | +- Save as CSV (Comma delimited) |
| 135 | + |
| 136 | +## 📞 Support |
| 137 | + |
| 138 | +Jika mengalami masalah: |
| 139 | + |
| 140 | +1. Cek error message di upload result |
| 141 | +2. Validasi format CSV menggunakan Excel atau Google Sheets |
| 142 | +3. Pastikan encoding file UTF-8 |
| 143 | +4. Test dengan 1-2 produk dulu sebelum upload banyak |
| 144 | + |
| 145 | +## 🎯 Tips |
| 146 | + |
| 147 | +1. **Start Small**: Test dengan 2-3 produk dulu |
| 148 | +2. **Validate Categories**: Pastikan kategori sudah dibuat di database |
| 149 | +3. **Unique Slugs**: Gunakan kombinasi nama + model untuk slug |
| 150 | +4. **Backup**: Simpan backup CSV sebelum upload |
| 151 | +5. **Monitor**: Cek upload history untuk melihat hasilnya |
| 152 | + |
| 153 | +--- |
| 154 | + |
| 155 | +Happy Bulk Uploading! 🚀 |
0 commit comments