File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed
packages/core/core-flows/src/product/helpers Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,29 @@ import type { ProductTypes } from "@medusajs/framework/types"
22import type { HttpTypes , RegionTypes } from "@medusajs/framework/types"
33import { MedusaError , lowerCaseFirst , normalizeCurrencyCode } from "@medusajs/framework/utils"
44
5- // We want to convert the csv data format to a standard DTO format.
5+ /**
6+ * Normalizes raw CSV product data into standardized AdminCreateProduct DTOs.
7+ *
8+ * This function converts product data from CSV import format to the standard DTO format
9+ * expected by the product creation API. It handles product grouping by handle,
10+ * variant aggregation, option extraction, and validation against existing regions and tags.
11+ *
12+ * @param rawProducts - Array of raw product objects from CSV import
13+ * @param additional - Additional context data needed for normalization
14+ * @param additional.regions - Available regions for price validation
15+ * @param additional.tags - Available product tags for validation
16+ * @returns Array of normalized AdminCreateProduct DTOs ready for import
17+ *
18+ * @throws {MedusaError } When referenced tags or regions are not found
19+ *
20+ * @example
21+ * ```typescript
22+ * const products = normalizeForImport(csvData, {
23+ * regions: existingRegions,
24+ * tags: existingTags
25+ * })
26+ * ```
27+ */
628export const normalizeForImport = (
729 rawProducts : object [ ] ,
830 additional : {
You can’t perform that action at this time.
0 commit comments