Import API: Products
This API will import products to your shop. Please note that this API will not create/generate product variants. For variants, please see the variants import API.
Import Items Structure
$importItems
The array of $importItems
should be structured as shown below. This should be passed to $padloper->import()
as the first argument:
$importItems = [
// fruit basket product
[
// title
'title' => ['default' => 'Fruit Basket', 'fi' => 'Hedelmäkori', 'de' => 'Früchtekorb'],
// ---------
// description
'padloper_description' => [
// default -> english
'default' => "Spoil someone with the luscious flavours and bright colours of our summery fruit baskets. Juicy pears are perfect for sinking your teeth into, while silky plums and fragrant mangoes melt against the tongue. For a deliciously shareable treat, there are also succulent slices of tangy pineapple. Spend over £50 to qualify for free delivery.",
// finnish
'fi' => "Hemmottele jotakuta kesäisten hedelmäkoriemme mehukkailla makuilla ja kirkkailla väreillä. Mehukkaat päärynät sopivat täydellisesti hampaiden upottamiseen, kun taas silkkiset luumut ja tuoksuvat mangot sulavat kieltä vasten. Herkullisen jaettavana herkkuna on myös meheviä viipaleita kirpeää ananasta. Käytä yli 50 puntaa saadaksesi ilmaisen toimituksen.",
// german
'de' => "Verwöhnen Sie jemanden mit den köstlichen Aromen und leuchtenden Farben unserer sommerlichen Obstkörbe. Saftige Birnen sind perfekt zum Hineinbeißen, während seidige Pflaumen und duftende Mangos auf der Zunge zergehen. Für eine köstliche Leckerei zum Teilen gibt es auch saftige Scheiben würziger Ananas. Geben Sie mehr als 50 £ aus, um sich für eine kostenlose Lieferung zu qualifizieren.",
],
// ---------
// stock
'padloper_product_stock' => [
'sku' => '00037235', // text
'price' => 35.00, // float
'comparePrice' => 39.75, // float
'quantity' => 1200, // int
'allowBackorders' => 0, // limited int: 0,1
'enabled' => 1, // limited int: 0,1
],
// ---------
// images
'padloper_images' => [
__DIR__ . "/temp_images/mixed-fruit-basket.png",
__DIR__ . "/temp_images/plums-1649316_1920.jpg",
__DIR__ . "/temp_images/strawberries.jpg",
],
// ---------
// settings
'padloper_product_settings' => [
'shippingType' => 'physical', // limited text: "physical" | "physical_no_shipping" | "digital" | "service"
'taxable' => 1, // limited int: 0,1
'trackInventory' => 1, // limited int: 0,1
'useVariants' => 1, // limited int: 0,1
"colour" => "#00FF00", // text
],
// ---------
// product attributes (multi page field)
// @note: for variants use!
// @note: SETTING pages as 'title of pages'
'padloper_product_attributes' => ['Size', 'Origin'],
// ---------
// downloads (multi page field)
// @note: SETTING with page titles OR ID
'padloper_downloads' => ['Fruit Salad Recipes', 3336],
// ---------
// type (single page field) @note: SETTING with page title
'padloper_type' => 'Food',
// ---------
// brand (single page field) @note: SETTING with page ID
'padloper_brand' => 1784,
// ---------
// categories (multi page field) @note: SETTING with page titles OR ID
'padloper_categories' => ['Wedding', 'Home Living', 1813],
// ---------
// tags (multi page field) @note: SETTING with page titles OR ID
'padloper_tags' => [1792, 'Perishable'],
// ---------
// properties @note: multi-dimensional since can have many properties!
'padloper_product_properties' => [
// property: weight
[
'value' => 3.5, // text
'propertyID' => "Weight", // int - WILL BE CONVERTED BY API to Page ID
'dimensionID' => "Kilograms", // int - WILL BE CONVERTED BY API to Page ID
],
// property: grade
[
'value' => "A", // text
// Grade
'propertyID' => 1774, // int
// Premium
'dimensionID' => "Premium", // int - WILL BE CONVERTED BY API to Page ID
],
// property: quality
[
'value' => '999', // text
// Quality
'propertyID' => "Quality", // int
// Premium
'dimensionID' => 1780, // int
],
],
]
// MORE PRODUCTS ...
];
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
$importType
The expected import type is products
. This should be passed to $padloper->import()
as the second argument.
$importOptions
If required, the following import options can be passed to $padloper->import()
as the third argument when importing products. This must be an array.
$importOptions = [
// @note: setting as unpublished!
'is_unpublished' => true
];
1
2
3
4
2
3
4
Example Import
The following example shows how to import several products into your shop. Please inspect the resultant array for import notifications.
// IMPORT ITEMS
$importItems = [
// rent a room product (service)
[
// @NOTE: IF MULTILINGUAL FIELD, WE EXPECT VALUE IS ARRAY; ELSE STRING
// title
'title' => ['default' => 'Rent a Room', 'fi' => 'Vuokraa Huone', 'de' => 'Ein Zimmer Mieten'],
// description
'padloper_description' => [
// default -> english
'default' => "1000s of rooms for rent in flatshares across London, Manchester, Birmingham, Bristol, Leeds, Edinburgh, Glasgow and the rest of the UK. Advertise for free!",
// finnish
'fi' => "1000 huonetta vuokrattavana huoneistoissa Lontoossa, Manchesterissa, Birminghamissa, Bristolissa, Leedsissä, Edinburghissa, Glasgow'ssa ja muualla Isossa-Britanniassa. Mainosta ilmaiseksi!",
// german
'de' => "Tausende Zimmer zu vermieten in WGs in London, Manchester, Birmingham, Bristol, Leeds, Edinburgh, Glasgow und dem Rest des Vereinigten Königreichs. Kostenlos inserieren!",
],
// ---------
// stock
'padloper_product_stock' => [
'sku' => 'RAT-999', // text
'price' => 4.99, // float
// "comparePrice" => 6.00, // float
'quantity' => 102, // int
'allowBackorders' => 1, // limited int: 0,1
'enabled' => 0, // limited int: 0,1
],
// ---------
// images
'padloper_images' => [
__DIR__ . "/temp_images/apartments.jpg",
__DIR__ . "/temp_images/building-5630441_1920.jpg",
__DIR__ . "/temp_images/door-ancient.jpg",
__DIR__ . "/temp_images/orange_house.jpg",
__DIR__ . "/temp_images/windows-5668674_1920.jpg",
],
// ---------
// settings
'padloper_product_settings' => [
'shippingType' => 'service', // limited text: "physical" | "physical_no_shipping" | "digital" | "service"
'taxable' => 0, // limited int: 0,1
'trackInventory' => 1, // limited int: 0,1
'useVariants' => 0, // limited int: 0,1
// colour => "", // text
],
],
// end: "rent a room"
// -------
// fruit basket product
[
// title
'title' => ['default' => 'Fruit Basket', 'fi' => 'Hedelmäkori', 'de' => 'Früchtekorb'],
// ---------
// description
'padloper_description' => [
// default -> english
'default' => "Spoil someone with the luscious flavours and bright colours of our summery fruit baskets. Juicy pears are perfect for sinking your teeth into, while silky plums and fragrant mangoes melt against the tongue. For a deliciously shareable treat, there are also succulent slices of tangy pineapple. Spend over £50 to qualify for free delivery.",
// finnish
'fi' => "Hemmottele jotakuta kesäisten hedelmäkoriemme mehukkailla makuilla ja kirkkailla väreillä. Mehukkaat päärynät sopivat täydellisesti hampaiden upottamiseen, kun taas silkkiset luumut ja tuoksuvat mangot sulavat kieltä vasten. Herkullisen jaettavana herkkuna on myös meheviä viipaleita kirpeää ananasta. Käytä yli 50 puntaa saadaksesi ilmaisen toimituksen.",
// german
'de' => "Verwöhnen Sie jemanden mit den köstlichen Aromen und leuchtenden Farben unserer sommerlichen Obstkörbe. Saftige Birnen sind perfekt zum Hineinbeißen, während seidige Pflaumen und duftende Mangos auf der Zunge zergehen. Für eine köstliche Leckerei zum Teilen gibt es auch saftige Scheiben würziger Ananas. Geben Sie mehr als 50 £ aus, um sich für eine kostenlose Lieferung zu qualifizieren.",
],
// ---------
// stock
'padloper_product_stock' => [
'sku' => '00037235', // text
'price' => 35.00, // float
'comparePrice' => 39.75, // float
'quantity' => 1200, // int
'allowBackorders' => 0, // limited int: 0,1
'enabled' => 1, // limited int: 0,1
],
// ---------
// images
'padloper_images' => [
__DIR__ . "/temp_images/apple-5183288_1920.jpg",
__DIR__ . "/temp_images/apples-805124_1920.jpg",
__DIR__ . "/temp_images/blueberries-870514_1920.jpg",
__DIR__ . "/temp_images/cherries-1503974_1920.jpg",
__DIR__ . "/temp_images/fruits-1114060_1920.jpg",
__DIR__ . "/temp_images/mixed-fruit-basket.png",
__DIR__ . "/temp_images/plums-1649316_1920.jpg",
__DIR__ . "/temp_images/strawberries.jpg",
],
// ---------
// settings
'padloper_product_settings' => [
'shippingType' => 'physical', // limited text: "physical" | "physical_no_shipping" | "digital" | "service"
'taxable' => 1, // limited int: 0,1
'trackInventory' => 1, // limited int: 0,1
'useVariants' => 1, // limited int: 0,1
'colour' => "#00FF00", // text
],
// ---------
// product attributes (multi page field)
// @note: for variants use!
// @note: SETTING pages as "title of pages"
'padloper_product_attributes' => ['Size', 'Origin'],
// ---------
// downloads (multi page field)
// @note: SETTING with page titles OR ID
'padloper_downloads' => ['Fruit Salad Recipes', 3336],
// ---------
// type (single page field) @note: SETTING with page title
'padloper_type' => 'Food',
// ---------
// brand (single page field) @note: SETTING with page ID
'padloper_brand' => 1784,
// ---------
// categories (multi page field) @note: SETTING with page titles OR ID
'padloper_categories' => ['Wedding', 'Home Living', 1813],
// ---------
// tags (multi page field) @note: SETTING with page titles OR ID
'padloper_tags' => [1792, 'Perishable'],
// ---------
// properties @note: multi-dimensional since can have many properties!
'padloper_product_properties' => [
// property: weight
[
'value' => 3.5, // text
'propertyID' => "Weight", // int - WILL BE CONVERTED BY API to Page ID
'dimensionID' => "Kilograms", // int - WILL BE CONVERTED BY API to Page ID
],
// property: grade
[
'value' => "A", // text
// Grade
'propertyID' => 1774, // int
// Premium
'dimensionID' => "Premium", // int - WILL BE CONVERTED BY API to Page ID
],
// property: quality
[
'value' => '999', // text
// Quality
'propertyID' => "Quality", // int
// Premium
'dimensionID' => 1780, // int
],
],
]
// end: fruit
];
// IMPORT OPTIONS
$importOptions = [
// @note: HERE WE ARE SETTING as unpublished; we will publish manually
'is_unpublished' => true
];
/** @var array $importResult */
$importResult = $padloper->import($importItems, 'products', $importOptions);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153