@haus-tech/product-import-export-plugin 3.1.3 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -0
- package/README.mdx +170 -0
- package/package.json +42 -4
- package/src/email.d.ts +6 -0
- package/src/email.js +11 -0
- package/src/email.js.map +1 -0
- package/src/index.d.ts +1 -0
- package/README.md +0 -91
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,37 @@
|
|
|
1
|
+
## 3.1.10
|
|
2
|
+
|
|
3
|
+
This was a version bump only for product-import-export-plugin to align it with other projects, there were no code changes.
|
|
4
|
+
|
|
5
|
+
## 3.1.9
|
|
6
|
+
|
|
7
|
+
This was a version bump only for product-import-export-plugin to align it with other projects, there were no code changes.
|
|
8
|
+
|
|
9
|
+
## 3.1.8
|
|
10
|
+
|
|
11
|
+
This was a version bump only for product-import-export-plugin to align it with other projects, there were no code changes.
|
|
12
|
+
|
|
13
|
+
## 3.1.7
|
|
14
|
+
|
|
15
|
+
This was a version bump only for product-import-export-plugin to align it with other projects, there were no code changes.
|
|
16
|
+
|
|
17
|
+
## 3.1.6
|
|
18
|
+
|
|
19
|
+
This was a version bump only for product-import-export-plugin to align it with other projects, there were no code changes.
|
|
20
|
+
|
|
21
|
+
## 3.1.5
|
|
22
|
+
|
|
23
|
+
This was a version bump only for product-import-export-plugin to align it with other projects, there were no code changes.
|
|
24
|
+
|
|
25
|
+
## 3.1.4
|
|
26
|
+
|
|
27
|
+
This was a version bump only for product-import-export-plugin to align it with other projects, there were no code changes.
|
|
28
|
+
|
|
29
|
+
## 3.1.3
|
|
30
|
+
|
|
31
|
+
### 🚀 Features
|
|
32
|
+
|
|
33
|
+
- enhance product import logic to handle soft-deleted products ([c88a164](https://github.com/WeAreHausTech/haus-tech-vendure-plugins/commit/c88a164))
|
|
34
|
+
|
|
1
35
|
## 3.1.2
|
|
2
36
|
|
|
3
37
|
### 🩹 Fixes
|
package/README.mdx
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: product-import-export-plugin
|
|
3
|
+
title: Product Import & Export Plugin
|
|
4
|
+
description: Vendure plugin for importing and exporting product data via CSV.
|
|
5
|
+
version: 3.1.3
|
|
6
|
+
tags:
|
|
7
|
+
- vendure
|
|
8
|
+
- plugin
|
|
9
|
+
- import
|
|
10
|
+
- export
|
|
11
|
+
- products
|
|
12
|
+
- csv
|
|
13
|
+
- bulk
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# Product Import Export Plugin
|
|
17
|
+
|
|
18
|
+
A Vendure plugin for importing and exporting product data via CSV. Supports bulk product management and data migration between environments.
|
|
19
|
+
|
|
20
|
+
## Features
|
|
21
|
+
|
|
22
|
+
- **Import** – Bulk upload products from CSV with validation, custom fields, assets, facets, and variants
|
|
23
|
+
- **Export** – Export products to CSV with selected fields; export all products or a selection
|
|
24
|
+
- **UI** – Admin UI and Dashboard integration for import and export
|
|
25
|
+
|
|
26
|
+

|
|
27
|
+
|
|
28
|
+
## Compatibility
|
|
29
|
+
|
|
30
|
+
Vendure **^2.0.0** or **^3.0.0**
|
|
31
|
+
|
|
32
|
+
## Getting started
|
|
33
|
+
|
|
34
|
+
```bash npm2yarn
|
|
35
|
+
npm install @haus-tech/product-import-export-plugin
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Configuration
|
|
39
|
+
|
|
40
|
+
Add the plugin to your Vendure configuration.
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
export const config = {
|
|
44
|
+
plugins: [
|
|
45
|
+
ProductImportExportPlugin.init({
|
|
46
|
+
importOptions: {}, // Configure import options
|
|
47
|
+
exportOptions: {}, // Configure export options
|
|
48
|
+
}),
|
|
49
|
+
],
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Configuration Options
|
|
54
|
+
|
|
55
|
+
### Import options
|
|
56
|
+
|
|
57
|
+
| Option | Type | Default | Description |
|
|
58
|
+
| -------------------- | --------- | ------- | -------------------------------------------------------------------------------------------------------------------------- |
|
|
59
|
+
| `updateProductSlug` | `boolean` | `true` | Update product slug from the `name` field in the CSV |
|
|
60
|
+
| `restoreSoftDeleted` | `boolean` | `true` | Restore soft-deleted products/variants found by id or SKU during import. If `false`, new products will be created instead. |
|
|
61
|
+
|
|
62
|
+
### Export options
|
|
63
|
+
|
|
64
|
+
| Option | Type | Default | Description |
|
|
65
|
+
| ----------------------- | --------------------- | ----------------------- | ------------------------------------------------- |
|
|
66
|
+
| `defaultFileName` | `string` | `'products_export.csv'` | Default filename for exports |
|
|
67
|
+
| `exportAssetsAsOptions` | `('url' \| 'json')[]` | `['url', 'json']` | Available formats for asset export |
|
|
68
|
+
| `defaultExportAssetsAs` | `'url' \| 'json'` | `'url'` | Default asset export format |
|
|
69
|
+
| `defaultExportFields` | `string[]` | See above | Fields that will be pre-selected in the export UI |
|
|
70
|
+
| `requiredExportFields` | `string[]` | `['name', 'sku']` | Fields that must always be included |
|
|
71
|
+
|
|
72
|
+
## CSV Format for Import
|
|
73
|
+
|
|
74
|
+
### Required columns
|
|
75
|
+
|
|
76
|
+
- `name` – Product name (use `name:en`, `name:sv` etc. for multiple languages)
|
|
77
|
+
- `sku` – Variant SKU (unique per variant)
|
|
78
|
+
|
|
79
|
+
### Optional columns
|
|
80
|
+
|
|
81
|
+
| Column | Format | Example |
|
|
82
|
+
| ----------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------------------------------------ |
|
|
83
|
+
| `name`, `slug`, `description` | Text, or `name:en`, `name:sv` for translations | `My Product` |
|
|
84
|
+
| `assets` | Pipe-separated URLs, or JSON `[{"url":"...","name":"..."}]` | `https://example.com/1.jpg\|https://example.com/2.jpg` |
|
|
85
|
+
| `facets` | `facet:value` pairs, pipe-separated | `Brand:Acme\|Category:Electronics` |
|
|
86
|
+
| `optionGroups` | Pipe-separated group names | `Size\|Color` |
|
|
87
|
+
| `optionValues` | Pipe-separated values (order matches option groups) | `Large\|Blue` |
|
|
88
|
+
| `price` | Number (in smallest currency unit) | `9999` |
|
|
89
|
+
| `taxCategory` | Tax category name | `standard` |
|
|
90
|
+
| `stockOnHand` | Number | `100` |
|
|
91
|
+
| `trackInventory` | `true` or `false` | `true` |
|
|
92
|
+
| `variantAssets` | Same format as `assets` | `https://example.com/variant.jpg` |
|
|
93
|
+
| `variantFacets` | Same format as `facets` | `Material:Cotton` |
|
|
94
|
+
| `enabled` | `true` or `false` | `true` |
|
|
95
|
+
| Custom fields | Column name = custom field name; value depends on field type | Add columns for any Product or ProductVariant custom fields defined in your Vendure config |
|
|
96
|
+
|
|
97
|
+
#### Multi-language support
|
|
98
|
+
|
|
99
|
+
Use language-specific columns by suffixing the field name with the language code. The language codes must match those configured in your Vendure instance (e.g. `en`, `sv`).
|
|
100
|
+
|
|
101
|
+
| Column pattern | Example columns | Use case |
|
|
102
|
+
| ------------------------ | ---------------------- | ------------------------------------------------ |
|
|
103
|
+
| `name:en`, `name:sv` | Product name per lang | Translated product names |
|
|
104
|
+
| `slug:en`, `slug:sv` | Slug per lang | Translated URLs |
|
|
105
|
+
| `description:en` | Description per lang | Translated descriptions |
|
|
106
|
+
| `facets:en`, `facets:sv` | Facets per lang | Translated facet names and values |
|
|
107
|
+
| `optionGroups:en` | Option groups per lang | Translated option group names (e.g. Size, Color) |
|
|
108
|
+
| `optionValues:en` | Option values per lang | Translated option values (e.g. Large, Blue) |
|
|
109
|
+
|
|
110
|
+
Example CSV with English and Swedish:
|
|
111
|
+
|
|
112
|
+
```csv
|
|
113
|
+
name:en,name:sv,sku,facets:en,facets:sv
|
|
114
|
+
"Red Shirt","Röd tröja",SHIRT-001,"Color:Red|Size:Large","Färg:Röd|Storlek:Stor"
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
#### Multiple values (pipe separator)
|
|
118
|
+
|
|
119
|
+
Fields that can have multiple values use the pipe character `|` as a separator:
|
|
120
|
+
|
|
121
|
+
- **Facets**: `Brand:Acme|Category:Electronics`
|
|
122
|
+
- **Option groups**: `Size|Color`
|
|
123
|
+
- **Option values**: `Large|Blue` (order matches option groups)
|
|
124
|
+
- **Assets**: `https://example.com/1.jpg|https://example.com/2.jpg`
|
|
125
|
+
|
|
126
|
+
## Usage
|
|
127
|
+
|
|
128
|
+
:::note
|
|
129
|
+
The Admin UI offers basic import and export. Some features such as the export-all option and the list of exported files are only available in the Dashboard. New features will be added to the Dashboard only.
|
|
130
|
+
:::
|
|
131
|
+
|
|
132
|
+
### Importing products
|
|
133
|
+
|
|
134
|
+
1. Create a CSV with the columns above.
|
|
135
|
+
2. Go to the Admin UI or Dashboard and open the Product Import section.
|
|
136
|
+
3. Upload the CSV and choose options (update slugs, restore soft-deleted, main language).
|
|
137
|
+
4. Select the update strategy: **merge** (keep existing facets/assets) or **replace** (overwrite).
|
|
138
|
+
5. Start the import.
|
|
139
|
+
|
|
140
|
+
### Exporting products
|
|
141
|
+
|
|
142
|
+
1. In the Admin UI or Dashboard, select products to export (or use bulk export).
|
|
143
|
+
2. Configure export fields (assets, facets, custom fields, etc.).
|
|
144
|
+
3. Choose asset format: URL or JSON.
|
|
145
|
+
4. Start the export (it is added to a job queue and runs in the background).
|
|
146
|
+
5. Download the CSV when the export is complete. Your downloaded files will be listed in the export view.
|
|
147
|
+
|
|
148
|
+

|
|
149
|
+
|
|
150
|
+
## Optional: Email notification on export complete
|
|
151
|
+
|
|
152
|
+
If you use `@vendure/email-plugin`, you can add an email notification when an export finishes by importing it in the handler from the `/email` subpath. Create a template in your email templates directory: `product-export-complete/body.hbs`
|
|
153
|
+
|
|
154
|
+
```typescript
|
|
155
|
+
import { DefaultEmailPlugin } from '@vendure/email-plugin'
|
|
156
|
+
import { productExportedHandler } from '@haus-tech/product-import-export-plugin/email'
|
|
157
|
+
|
|
158
|
+
export const config = {
|
|
159
|
+
plugins: [
|
|
160
|
+
DefaultEmailPlugin.init({
|
|
161
|
+
handlers: [productExportedHandler],
|
|
162
|
+
}),
|
|
163
|
+
],
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## Resources
|
|
168
|
+
|
|
169
|
+
- [Vendure Plugin Documentation](https://docs.vendure.io/guides/developer-guide/plugins/)
|
|
170
|
+
- [Vendure Import/Export Guide](https://docs.vendure.io/guides/developer-guide/importing-data/)
|
package/package.json
CHANGED
|
@@ -1,31 +1,69 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haus-tech/product-import-export-plugin",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "A Vendure plugin for importing and exporting products using a CSV file",
|
|
5
5
|
"author": "Haus Tech",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/WeAreHausTech/haus-tech-vendure-plugins.git"
|
|
8
|
+
"url": "git+https://github.com/WeAreHausTech/haus-tech-vendure-plugins-public.git"
|
|
9
9
|
},
|
|
10
10
|
"license": "MIT",
|
|
11
|
+
"keywords": [
|
|
12
|
+
"vendure",
|
|
13
|
+
"plugin",
|
|
14
|
+
"import",
|
|
15
|
+
"export",
|
|
16
|
+
"products",
|
|
17
|
+
"csv",
|
|
18
|
+
"bulk"
|
|
19
|
+
],
|
|
11
20
|
"engines": {
|
|
12
21
|
"node": ">=20.0.0"
|
|
13
22
|
},
|
|
14
23
|
"main": "src/index.js",
|
|
15
24
|
"types": "src/index.d.ts",
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./src/index.d.ts",
|
|
28
|
+
"default": "./src/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./email": {
|
|
31
|
+
"types": "./src/email.d.ts",
|
|
32
|
+
"default": "./src/email.js"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"src",
|
|
37
|
+
"assets",
|
|
38
|
+
"README.mdx",
|
|
39
|
+
"CHANGELOG.md"
|
|
40
|
+
],
|
|
16
41
|
"scripts": {
|
|
17
|
-
"start": "yarn ts-node test/dev-server.ts"
|
|
42
|
+
"start": "yarn ts-node test/dev-server.ts",
|
|
43
|
+
"build": "yarn run -T rimraf dist && yarn run -T tsc && yarn run -T copyfiles -u 1 'src/ui/**/*' dist/"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"axios": "^1.7.0",
|
|
47
|
+
"bottleneck": "^2.19.5",
|
|
48
|
+
"fs-extra": "^11.2.0",
|
|
49
|
+
"lodash": "^4.17.21"
|
|
18
50
|
},
|
|
19
51
|
"devDependencies": {
|
|
20
52
|
"@types/fs-extra": "^11.0.4",
|
|
21
|
-
"bottleneck": "^2.19.5",
|
|
22
53
|
"csv-parse": "^5.6.0",
|
|
23
54
|
"csv-stringify": "^6.6.0"
|
|
24
55
|
},
|
|
25
56
|
"peerDependencies": {
|
|
57
|
+
"@vendure/core": "^2.0.0 || ^3.0.0",
|
|
58
|
+
"@vendure/email-plugin": "^2.0.0 || ^3.0.0",
|
|
26
59
|
"csv-parse": "^5.5.6",
|
|
27
60
|
"csv-stringify": "^6.5.1",
|
|
28
61
|
"slug": "^9.1.0"
|
|
29
62
|
},
|
|
63
|
+
"peerDependenciesMeta": {
|
|
64
|
+
"@vendure/email-plugin": {
|
|
65
|
+
"optional": true
|
|
66
|
+
}
|
|
67
|
+
},
|
|
30
68
|
"type": "commonjs"
|
|
31
69
|
}
|
package/src/email.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Re-export of the product exported email handler for use with @vendure/email-plugin.
|
|
3
|
+
* Import from '@haus-tech/product-import-export-plugin/email'.
|
|
4
|
+
* Requires @vendure/email-plugin to be installed.
|
|
5
|
+
*/
|
|
6
|
+
export { productExportedHandler } from './handlers/product-exported.handler';
|
package/src/email.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.productExportedHandler = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Re-export of the product exported email handler for use with @vendure/email-plugin.
|
|
6
|
+
* Import from '@haus-tech/product-import-export-plugin/email'.
|
|
7
|
+
* Requires @vendure/email-plugin to be installed.
|
|
8
|
+
*/
|
|
9
|
+
var product_exported_handler_1 = require("./handlers/product-exported.handler");
|
|
10
|
+
Object.defineProperty(exports, "productExportedHandler", { enumerable: true, get: function () { return product_exported_handler_1.productExportedHandler; } });
|
|
11
|
+
//# sourceMappingURL=email.js.map
|
package/src/email.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email.js","sourceRoot":"","sources":["../../../../packages/product-import-export-plugin/src/email.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,gFAA4E;AAAnE,kIAAA,sBAAsB,OAAA"}
|
package/src/index.d.ts
CHANGED
package/README.md
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: product-import-export-plugin
|
|
3
|
-
title: Product Import Export Plugin
|
|
4
|
-
description: Vendure plugin designed to simplify the process of importing and exporting product data.
|
|
5
|
-
version: 3.1.0
|
|
6
|
-
tags: [vendure, plugin, import, export]
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
# Product Import Export Plugin
|
|
10
|
-
|
|
11
|
-
The Product Import Export Plugin is a Vendure plugin designed to simplify the process of importing and exporting product data. It provides an efficient way to manage large catalogs, migrate data between environments, and integrate with external systems.
|
|
12
|
-
|
|
13
|
-
## Functionality
|
|
14
|
-
|
|
15
|
-
This plugin enables the following features:
|
|
16
|
-
|
|
17
|
-
- Importing product data from CSV files with validation and support for custom fields.
|
|
18
|
-
- Exporting product data to CSV files with customizable fields, including custom fields and asset data.
|
|
19
|
-
- Integration with the Vendure Admin UI for importing and exporting products.
|
|
20
|
-
- Configurable options for import/export behavior, such as updating product slugs and handling translations.
|
|
21
|
-
|
|
22
|
-
## Use Cases
|
|
23
|
-
|
|
24
|
-
The Product Import Export Plugin is ideal for:
|
|
25
|
-
|
|
26
|
-
- Bulk uploading product data into a Vendure instance.
|
|
27
|
-
- Exporting product data for reporting or integration with third-party systems.
|
|
28
|
-
- Migrating product data between different Vendure environments.
|
|
29
|
-
|
|
30
|
-
## Installation
|
|
31
|
-
|
|
32
|
-
1. Clone the repository or copy the `product-import-export-plugin` directory into your project.
|
|
33
|
-
2. Navigate to the plugin directory:
|
|
34
|
-
|
|
35
|
-
```bash
|
|
36
|
-
cd packages/product-import-export-plugin
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
3. Install the dependencies:
|
|
40
|
-
|
|
41
|
-
```bash
|
|
42
|
-
yarn
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
4. Build the plugin:
|
|
46
|
-
|
|
47
|
-
```bash
|
|
48
|
-
yarn build
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
5. Add the plugin to your Vendure configuration:
|
|
52
|
-
|
|
53
|
-
```typescript
|
|
54
|
-
import { ProductImportExportPlugin } from 'product-import-export-plugin';
|
|
55
|
-
|
|
56
|
-
export const config = {
|
|
57
|
-
plugins: [
|
|
58
|
-
ProductImportExportPlugin,
|
|
59
|
-
// other plugins
|
|
60
|
-
],
|
|
61
|
-
};
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
## Usage
|
|
65
|
-
|
|
66
|
-
### Importing Products
|
|
67
|
-
|
|
68
|
-
1. Prepare a CSV file with the product data. Ensure the file matches the required format, including headers for custom fields if applicable.
|
|
69
|
-
2. Use the Admin UI or API to upload the CSV file for import.
|
|
70
|
-
3. The plugin will validate and process the file, creating or updating products in the database.
|
|
71
|
-
|
|
72
|
-
### Exporting Products
|
|
73
|
-
|
|
74
|
-
1. Use the Admin UI or API to select products for export.
|
|
75
|
-
2. Customize the fields to be included in the export, such as custom fields and asset data.
|
|
76
|
-
3. Download the generated CSV file for further use.
|
|
77
|
-
|
|
78
|
-
## Testing
|
|
79
|
-
|
|
80
|
-
1. Run the end-to-end tests:
|
|
81
|
-
|
|
82
|
-
```bash
|
|
83
|
-
yarn test
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
2. Modify the tests in `test/e2e.spec.ts` to suit your plugin's functionality.
|
|
87
|
-
|
|
88
|
-
## Resources
|
|
89
|
-
|
|
90
|
-
- [Vendure Plugin Documentation](https://www.vendure.io/docs/plugins/)
|
|
91
|
-
- [GraphQL Code Generator](https://the-guild.dev/graphql/codegen) for generating TypeScript types for custom GraphQL types.
|