# `PhoenixKitCatalogue.Import.Executor`
[🔗](https://github.com/BeamLabEU/phoenix_kit_catalogue/blob/0.1.14/lib/phoenix_kit_catalogue/import/executor.ex#L1)

Executes an import plan by creating categories and items.

Categories are created first (get-or-create pattern), then items
are inserted with progress reporting back to the calling process.

# `import_result`

```elixir
@type import_result() :: %{
  created: non_neg_integer(),
  errors: [{non_neg_integer(), String.t()}],
  categories_created: non_neg_integer(),
  manufacturers_created: non_neg_integer(),
  suppliers_created: non_neg_integer(),
  manufacturer_supplier_links_created: non_neg_integer()
}
```

# `execute`

```elixir
@spec execute(map(), String.t(), pid(), keyword()) :: import_result()
```

Executes an import plan.

Phase 1: get-or-create categories / manufacturers / suppliers
(column mode only — fixed-uuid modes skip phase 1 for the
corresponding entity). Phase 2: insert items, resolving
`category_uuid` / `manufacturer_uuid` per row from the lookups
built in phase 1 (or the fixed UUIDs). Phase 3: link
manufacturers↔suppliers (M:N). Sends `{:import_progress, current,
total}` messages to `notify_pid` after each item.

## Options

  * `:language` — language code for multilang import (e.g. `"et"`)
  * `:category_uuid` — fixed category UUID to assign all items to
  * `:match_categories_across_languages` — when `true`, the
    get-or-create lookup for column-mode category creation matches
    column values against every translation any existing category
    has, not just the current import language. Default `false`.
  * `:manufacturer_uuid` — fixed manufacturer UUID to assign all
    items to (skips phase 1 manufacturer creation)
  * `:supplier_uuid` — fixed supplier UUID; in phase 3 this supplier
    is linked (M:N) to every distinct manufacturer the items in
    this import ended up assigned to

---

*Consult [api-reference.md](api-reference.md) for complete listing*
