Import Documents

Import documents using the Magento Import UI or via CLI.

Import Process

Step 1: Prepare CSV File

Create a CSV file with the required columns. See CSV Format for details.

Step 2: Provide Files (new documents)

For new documents, path must point to a real file on disk (relative to Magento root). Example:

var/import/customerdocuments/test_1.pdf

During import, the file is copied into the configured upload folder (customerdocuments/general/upload_path) and the stored document path is updated.

Step 3: Run Import

Via Admin:

  1. Go to System > Data Transfer > Import
  2. Select Entity Type: Customer Documents
  3. Upload your CSV file
  4. Click Check Data (recommended)
  5. Click Import

Via CLI:

php bin/magento customerdocuments:import-customerdocuments /path/to/file.csv

Import Behaviors

Behavior Description
Append / Add/Update Create documents (no id) and update existing ones (with id).
Replace Deletes the documents referenced by id in the CSV and re-imports them (useful for “replacing” a file/row).
Delete Deletes the documents referenced by id in the CSV.

Validation

Use Check Data in the Admin Import UI first. The importer validates:

  • required fields (name, description, and path for new docs)
  • customers (expects emails in customer_ids)
  • customer groups (expects group codes in customer_group_ids)
  • category (expects a category name in category_id)
  • product_links syntax (expects sku@store_code@position entries separated by |)
  • file exists at the given path
  • file extension allowed by customerdocuments/general/allowed_extensions

Import Options

Option Description
import_path Required CLI argument (CSV file path)
--behavior append, add_update, replace, delete (default append)
--field_separator Field separator (default ,)
--field_multiple_value_separator Default ,
--fields_enclosure Default 0
--delete_file_after_import Delete CSV after import (default 1)

Updating Without Changing Files

If you set id (existing document id), path is not required. This lets you update metadata (assignments, validity, tags, etc.) without re-uploading a file.

Found an issue with this documentation? Let us know