vendure icon indicating copy to clipboard operation
vendure copied to clipboard

CSV import does not import non translatable custom fields correctly

Open jnugh opened this issue 2 years ago • 2 comments

Describe the bug When doing a CSV import e.g. during an e2e test custom fields are not being imported correctly if they are not translatable. The customFields are being exported to the translated entity instead.

Check: https://github.com/vendure-ecommerce/vendure/blob/master/packages/core/src/data-import/providers/import-parser/import-parser.ts#L401C20-L401C50

parsedCustomFields is being created and stored in the translation. customFields are never being assigned to parsedProduct .

        const parsedProduct: ParsedProduct = {
            assetPaths: parseStringArray(r.assets),
            optionGroups,
            facets,
            translations,
        };

To Reproduce Steps to reproduce the behavior:

  1. Create a CSV file with variant:customFieldName where customFieldName is a non-translatable custom field
  2. Import the CSV
  3. The custom field has a default value in the database

Expected behavior The field should be populated from the CSV file

Environment (please complete the following information):

  • @vendure/core version: 2.1 (but the code looks the same on master)
  • Nodejs version: 20
  • Database (mysql/postgres etc): psotgres

Additional context I'd gladly create a PR for this issue.

jnugh avatar Apr 16 '24 10:04 jnugh

This version 2.1.8 issue could be related as well: https://discord.com/channels/1100672177260478564/1222882518139801631/1222882518139801631 Unfortunately, I won't have time to look at issues with translations until begin of May.

hans-rollingridges-dev avatar Apr 16 '24 19:04 hans-rollingridges-dev

The linked message is not related to the CSV import. There is also a pretty obvious fix I could create a PR for. Just wanted to create an issue before creating a Pull Request because this is how it's described in CONTRIBUTING.md.

jnugh avatar Apr 17 '24 09:04 jnugh