## Importing Product Costs via CSV

CSV import is the fastest way to add or update costs for many products at once. Whether you're setting up Alpha Insights for the first time or receiving updated pricing from suppliers, importing from a spreadsheet saves hours of manual data entry.

### When to Use CSV Import

#### Initial Setup

If you have costs in an existing spreadsheet, database, or another system, CSV import lets you add all costs at once instead of entering them individually.

#### Supplier Price Updates

When suppliers send you updated price sheets, convert their format to match Alpha Insights' CSV format and import - much faster than updating products one by one.

#### Multi-Source Cost Data

If you get costs from multiple suppliers or sources, compile them into one CSV file and import everything in a single operation.

#### Periodic Cost Reviews

Export your costs, review and adjust them in Excel or Google Sheets, then re-import the updated values.

### Preparing Your CSV File

#### Required Columns

Your CSV file must include these two columns (order doesn't matter):

1. Product Identifier (choose one):

- Product ID: The WooCommerce post ID (numerical, e.g., 123, 456)
- SKU: The product SKU / Stock Keeping Unit (e.g., T-SHIRT-S, HAT-01)

2. Cost Column:

- Use decimal format: 12.50, not $12.50
- Don't include currency symbols
- Decimal separator can be period (12.50) or comma (12,50) - Alpha Insights handles both
- Zero (0 or 0.00) is a valid cost for free items
- Empty cost cells will remove the custom cost from that product

#### CSV Format Examples

Example 1: Using Product ID

    Product ID,Cost 123,25.50 124,18.00 125,32.75

Example 2: Using SKU

    SKU,Cost T-SHIRT-S,12.50 T-SHIRT-M,12.50 T-SHIRT-L,13.00 HAT-BLUE-01,8.50

Example 3: Additional Columns (Ignored)

You can include other columns - they'll be ignored:

    SKU,Product Name,Cost,Supplier T-SHIRT-S,T-Shirt Small,12.50,ABC Corp HAT-01,Blue Baseball Hat,8.50,XYZ Ltd

Alpha Insights only reads the identifier (SKU) and Cost columns.

#### Getting Product IDs or SKUs

If you're not sure of your product IDs or SKUs:

1. Go to Alpha Insights → Cost of Goods Manager
2. Click Export CSV
3. Open the exported file - it contains all your product IDs and SKUs
4. Use this as a template: delete the columns you don't need, keep ID/SKU and Cost

#### Excel/Google Sheets Preparation

In Excel:

1. Create or open your spreadsheet
2. Ensure column headers are in Row 1: "SKU" (or "Product ID") and "Cost"
3. Fill in your data
4. Click File → Save As
5. Choose format:CSV (Comma delimited) (*.csv)
6. Save the file

In Google Sheets:

1. Create or open your spreadsheet
2. Ensure proper column headers
3. Click File → Download → Comma Separated Values (.csv)
4. Save to your computer

### Importing the CSV File

#### Step-by-Step Import Process

1. Go to Alpha Insights → Cost of Goods Manager
2. Click the Import CSV button in the toolbar
3. A modal window opens with import options

#### Choose Identifier Type

Select which identifier your CSV uses:

- Product ID: If your CSV has numerical IDs (123, 456, etc.)
- SKU: If your CSV has text SKUs (T-SHIRT-S, HAT-01, etc.)

Important: Choose the correct type! If you select "SKU" but your CSV has IDs, products won't be found.

#### Upload Your File

1. Click Choose File or Browse
2. Select your CSV file from your computer
3. Click Open

#### Preview and Confirm

Alpha Insights shows a preview of your file:

- First few rows displayed
- Column headers identified
- Number of rows to process

Review this carefully:

- Do the columns look correct?
- Are the product identifiers showing properly?
- Are the cost values formatted correctly?

If something looks wrong, click Cancel, fix your CSV, and try again.

#### Start Import

1. If the preview looks good, click Start Import or Import
2. A progress indicator shows as products are processed
3. Processing happens one row at a time
4. For large files (1,000+ products), this may take 1-2 minutes

#### Import Results

When complete, you'll see a summary:

- Total rows processed: How many lines were in your CSV
- Successfully updated: Products that were found and updated
- Skipped/Failed: Products that couldn't be found or had errors
- Error details: List of any products that failed (with reason)

### What Happens During Import

#### For Each Row in Your CSV:

1. Alpha Insights searches for the product by ID or SKU
2. - Cost is validated (must be numeric)
   - Cost is saved to the product
   - Profit cache for orders containing this product is cleared
   - Counter increments
3. - Row is skipped
   - Error is logged with the identifier that failed

#### Existing Costs

Import overwrites existing costs:

- If a product has a cost already, the CSV value replaces it
- If a product has no cost, the CSV value is added
- If the CSV has a zero cost (0 or 0.00), it's saved as zero - this is a valid cost
- If the CSV has an empty cost value, the custom cost is removed and the product reverts to using the default calculated cost

There's no "merge" or "skip existing" option - CSV import is for bulk updates.

#### Validation

Alpha Insights validates each row:

- Product identifier: Must exist in your store
- Cost value: Must be numeric (12.50 is valid, "twelve dollars" is not)
- Format: Handles international decimal formats automatically

Invalid rows are skipped with an error message - valid rows still process.

### Common CSV Import Scenarios

#### Scenario 1: First-Time Cost Setup

You have 500 products and a supplier gave you a price list in Excel.

1. Open supplier's Excel file
2. Add your product SKUs to their list (match their products to yours)
3. Format as: SKU | Cost (delete other columns)
4. Save as CSV
5. Import using SKU identifier type
6. Review results to see which products matched

Tip: Some products might not match if SKUs differ. Check the error list and fix those manually.

#### Scenario 2: Quarterly Price Increase

Your supplier increased all costs by 8%.

1. Export your current costs from Cost Manager
2. Open in Excel
3. Create formula in new column: =Cost * 1.08
4. Copy formula down
5. Delete old cost column, rename new column to "Cost"
6. Keep SKU or Product ID column
7. Save as CSV and import

#### Scenario 3: Multiple Suppliers

You source from 3 different suppliers, each with their own price sheets.

1. Export Alpha Insights costs for all products
2. Open in Excel
3. - Match their products to your SKUs
   - Update costs in the main spreadsheet
4. Save combined file as CSV
5. Import once with all updated costs

#### Scenario 4: New Variable Products

You added a new shirt with 10 color/size variations, each with different costs.

1.     SKU,Cost SHIRT-S-RED,12.00 SHIRT-S-BLUE,12.00 SHIRT-M-RED,12.50 SHIRT-M-BLUE,12.50 ...

2. Import this small file
3. All variations get costs added at once

### Troubleshooting CSV Imports

#### "File upload failed"

Causes:

- File is too large (over WordPress upload limit)
- File isn't actually a CSV
- Server permissions issue

Solutions:

- Check file size - split large files into smaller batches
- Ensure file ends in .csv
- Resave from Excel as CSV (not XLSX)
- Contact host if upload limits are an issue

#### "No products were updated"

Causes:

- Wrong identifier type selected
- Product IDs or SKUs don't match your actual products
- Column headers missing or incorrect

Solutions:

- Export a sample CSV from Alpha Insights to check your products' actual IDs/SKUs
- Verify column headers are exactly "Product ID" or "SKU" and "Cost"
- Try the opposite identifier type (ID vs SKU)

#### "Some products failed to import"

This is normal if:

- CSV has products you've since deleted from WooCommerce
- SKUs in CSV don't exactly match (case-sensitive, spacing matters)
- Some costs have invalid characters ($, commas, etc.)

Solution:

- Review the error list in import results
- For failed products, add them manually or fix the CSV row and re-import just those

#### "Costs importing as wrong values"

Causes:

- Excel formatting costs as currency (with symbols)
- Decimal separator confusion (1,50 vs 1.50)
- Scientific notation (1.2E+5)

Solutions:

- In Excel, format cost column as "Number" with 2 decimal places
- Remove currency symbols before saving
- Alpha Insights handles both comma and period decimals, but choose one consistently

#### "Import is very slow"

Large files (1,000+ products) can take time.

Normal behavior:

- 1,000 products: ~1-2 minutes
- 5,000 products: ~5-10 minutes

If it's much slower:

- Check your server performance
- Consider splitting into smaller batches
- Do imports during low-traffic times

### Best Practices

#### Test with Small Sample First

Before importing 5,000 products:

1. Create a test CSV with just 5-10 products
2. Import and verify results
3. If successful, proceed with full file

#### Backup Before Large Imports

1. Export current costs before importing updates
2. Save the export as a backup
3. If import goes wrong, re-import the backup

#### Use SKUs When Possible

SKUs are more reliable than Product IDs because:

- IDs can change if you migrate sites
- SKUs are more human-readable
- Easier to match with supplier data

Only use Product IDs if you don't have SKUs set up.

#### Clean Your Data First

Before importing:

- Remove extra spaces from SKUs/costs
- Ensure all costs are numeric
- Delete any completely empty rows
- Verify column headers are exactly correct

#### Document Your Import

Keep track of imports:

- Save dated copies of import files
- Note why/when you did each import
- Screenshot or save the import results

This helps if you need to troubleshoot later.

### Alternative Import Methods

#### If CSV Import Isn't Working

You have other options:

1. Cost Manager Manual Entry: For small numbers of products (under 50), manual entry in Cost Manager is often fastest.

2. Individual Product Edit: Edit products one-by-one in WooCommerce.

3. Database Import: For very large imports (10,000+ products), developers can directly update the database using SQL - contact support for guidance.

4. API Integration: If you have a developer, costs can be updated programmatically via REST API or PHP functions.