PhoenixKit.Modules.Shop.Import.ImportFormat behaviour (phoenix_kit v1.7.71)

Copy Markdown View Source

Behaviour for CSV import format adapters.

All CSV format modules (Shopify, Prom.ua, etc.) implement this behaviour to provide a uniform interface for the import pipeline.

Summary

Callbacks

Counts the number of products that will be imported from the file.

Returns default attrs for seeding an ImportConfig for this format.

Returns true if the given CSV headers match this format.

Parses CSV and returns a list/stream of product attrs maps ready for Shop.upsert_product/1.

Whether the :configure wizard step (option mapping UI) should be shown.

Callbacks

count(path, config)

@callback count(
  path :: String.t(),
  config :: PhoenixKit.Modules.Shop.ImportConfig.t() | nil
) ::
  non_neg_integer()

Counts the number of products that will be imported from the file.

default_config_attrs()

@callback default_config_attrs() :: map()

Returns default attrs for seeding an ImportConfig for this format.

detect?(headers)

@callback detect?(headers :: [String.t()]) :: boolean()

Returns true if the given CSV headers match this format.

parse_and_transform(path, categories_map, config, opts)

@callback parse_and_transform(
  path :: String.t(),
  categories_map :: map(),
  config :: PhoenixKit.Modules.Shop.ImportConfig.t() | nil,
  opts :: keyword()
) :: Enumerable.t()

Parses CSV and returns a list/stream of product attrs maps ready for Shop.upsert_product/1.

requires_option_mapping?()

@callback requires_option_mapping?() :: boolean()

Whether the :configure wizard step (option mapping UI) should be shown.