PhoenixKit.Modules.Shop.Import.CSVParser (phoenix_kit v1.7.71)

Copy Markdown View Source

Parse Shopify CSV and group rows by Handle.

Shopify CSV structure:

  • First row with product data contains title, description, etc.
  • Subsequent rows for same Handle contain variant data only (empty title/description)
  • Each variant row has Option1/Option2 values and prices

Summary

Functions

Get the first (main) row for a product group. Contains title, description, and other product-level data.

Parse CSV file and group rows by Handle (product identifier).

Get all variant rows (rows with price data).

Functions

main_row(rows)

Get the first (main) row for a product group. Contains title, description, and other product-level data.

parse_and_group(file_path)

Parse CSV file and group rows by Handle (product identifier).

Returns a map where keys are handles and values are lists of row maps.

Examples

CSVParser.parse_and_group("/path/to/products.csv")
# => %{
#   "product-handle" => [
#     %{"Handle" => "product-handle", "Title" => "Product", ...},
#     %{"Handle" => "product-handle", "Option1 Value" => "Small", ...},
#     ...
#   ],
#   ...
# }

variant_rows(rows)

Get all variant rows (rows with price data).