Implemented a new text-based import format for bulk product imports that is easier to read, write, and version control compared to CSV format. ## New Features ### Import Service (ProductImportService.cs) - Added `ImportFromHumanTextAsync()` - Main text format parser - Added `GenerateTemplateAsHumanText()` - Template generator - Parser supports: - Product blocks starting with `#` - Descriptions between `<text>` tags (optional) - Key-value properties (category, price, weight, unit, stock) - Variants (lines starting with `-`) - Multi-buy offers (lines starting with `+`) - Variant collections (optional, after product name) ### Admin UI - New controller actions: - `ImportText()` - GET: Show import form - `ImportText(textContent, file)` - POST: Process import - `DownloadTextTemplate()` - Download .txt template - New view: `ImportText.cshtml` - Textarea for pasting text - File upload for .txt files - Format documentation sidebar - Links to CSV import and template downloads - Updated `Index.cshtml` with dropdown menu for import options ### Template & Documentation - Created `docs/ProductImportTemplate.txt` with 7 example products - Demonstrates all format features: - Products with/without descriptions - Variants with stock levels - Multi-buy pricing tiers - Multiple weight units ## Text Format Specification ``` # Product Name; OptionalVariantCollection <text> Multi-line description (optional) </text> category: CategoryName price: 10.00 weight: 100 unit: Grams stock: 50 - Variant1; 8.00; 50 - Variant2; 12.00; 30 + Multi-buy1; 2; 19.00 + Multi-buy2; 3; 25.00 ``` ## Benefits - ✅ Git-friendly (easy to diff and version) - ✅ Human-readable and editable - ✅ Supports all product features - ✅ Multi-line descriptions - ✅ Clear structure with # delimiters - ✅ Optional fields (description, variants, multi-buys) - ✅ Comprehensive error reporting 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
127 lines
2.5 KiB
Plaintext
127 lines
2.5 KiB
Plaintext
# Product Import Template (Human-Readable Text Format)
|
|
#
|
|
# This template demonstrates how to import products using the human-readable text format.
|
|
#
|
|
# Format:
|
|
# - Each product block starts with # followed by product name
|
|
# - Optional variant collection name after semicolon: # Product Name; Variant Collection
|
|
# - Description between <text> and </text> tags (optional)
|
|
# - Required fields: category, price, weight, unit, stock
|
|
# - Variants: lines starting with - (hyphen)
|
|
# - Multi-buys: lines starting with + (plus)
|
|
#
|
|
# Delete these comment lines before importing!
|
|
|
|
# Organic Coffee Beans; Size Options
|
|
<text>
|
|
Premium organic coffee beans sourced from sustainable farms.
|
|
Perfect for espresso or filter coffee.
|
|
Freshly roasted to order for maximum flavor and aroma.
|
|
</text>
|
|
category: Beverages
|
|
price: 12.00
|
|
weight: 250
|
|
unit: Grams
|
|
stock: 100
|
|
|
|
- 250g; 12.00; 50
|
|
- 500g; 22.00; 30
|
|
- 1kg; 40.00; 20
|
|
|
|
+ Single Bag; 1; 12.00
|
|
+ Twin Pack; 2; 22.00
|
|
+ Family Pack; 3; 32.00
|
|
|
|
# Artisan Chocolate Bar
|
|
<text>
|
|
Handcrafted dark chocolate made with 70% cacao.
|
|
Vegan and gluten-free.
|
|
Made in small batches for exceptional quality.
|
|
</text>
|
|
category: Confectionery
|
|
price: 3.50
|
|
weight: 100
|
|
unit: Grams
|
|
stock: 200
|
|
|
|
+ Single Bar; 1; 3.50
|
|
+ Box of 6; 6; 18.00
|
|
+ Box of 12; 12; 35.00
|
|
|
|
# Premium Tea Blend
|
|
<text>
|
|
A harmonious blend of black tea, bergamot, and lavender.
|
|
Perfect for afternoon tea or as a calming evening drink.
|
|
</text>
|
|
category: Beverages
|
|
price: 8.50
|
|
weight: 50
|
|
unit: Grams
|
|
stock: 75
|
|
|
|
- 50g Tin; 8.50; 40
|
|
- 100g Tin; 15.00; 25
|
|
- 250g Bulk; 32.00; 10
|
|
|
|
+ Single Tin; 1; 8.50
|
|
+ Tea Duo; 2; 16.00
|
|
|
|
# Natural Honey
|
|
<text>
|
|
Raw, unfiltered honey from local beekeepers.
|
|
Rich in antioxidants and natural enzymes.
|
|
Perfect for sweetening tea or spreading on toast.
|
|
</text>
|
|
category: Pantry Staples
|
|
price: 9.99
|
|
weight: 340
|
|
unit: Grams
|
|
stock: 150
|
|
|
|
- 340g Jar; 9.99; 80
|
|
- 680g Jar; 17.99; 50
|
|
- 1kg Bulk; 24.99; 20
|
|
|
|
# Handmade Soap Bar
|
|
category: Personal Care
|
|
price: 5.50
|
|
weight: 120
|
|
unit: Grams
|
|
stock: 300
|
|
|
|
- Lavender; 5.50; 100
|
|
- Peppermint; 5.50; 100
|
|
- Eucalyptus; 5.50; 100
|
|
|
|
+ Single Bar; 1; 5.50
|
|
+ Gift Set of 3; 3; 15.00
|
|
|
|
# Organic Olive Oil
|
|
<text>
|
|
Extra virgin olive oil from family-owned groves in Italy.
|
|
Cold-pressed for superior quality and flavor.
|
|
Ideal for cooking, salads, and dipping.
|
|
</text>
|
|
category: Pantry Staples
|
|
price: 14.99
|
|
weight: 500
|
|
unit: Grams
|
|
stock: 60
|
|
|
|
+ 500ml Bottle; 1; 14.99
|
|
+ Twin Pack; 2; 27.99
|
|
|
|
# Gourmet Popcorn
|
|
category: Snacks
|
|
price: 4.25
|
|
weight: 200
|
|
unit: Grams
|
|
stock: 180
|
|
|
|
- Sweet & Salty; 4.25; 60
|
|
- Caramel; 4.25; 60
|
|
- Cheese; 4.25; 60
|
|
|
|
+ Single Pack; 1; 4.25
|
|
+ Variety Pack (3); 3; 11.99
|