Import API: Attribute Options

This API will import product attribute options to your shop. Attribute options are required if you need to create product variants.

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 = [
  // half board attribute option
  [
    // @NOTE: IF MULTILINGUAL FIELD, WE EXPECT VALUE IS ARRAY; ELSE STRING
    // title
    'title' => [
      'default' => 'Half Board',
      'fi' => 'Puolihoito',
      'de' => 'Halbpension'
    ],
    // attribute parent can passed as PARENT TITLE OR PARENT ID
    'parent' => 'Accommodation'
  ],
  // MORE ATTRIBUTE OPTIONS ...
];
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

$importType

The expected import type is attribute_options. 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 attribute options. This must be an array.

$importOptions = [
   // @note: setting as unpublished!
  'is_unpublished' => true
];
1
2
3
4

Example Import

The following example shows how to import several attribute options into your shop. Please inspect the resultant array for import notifications.

// IMPORT ITEMS
$importItems = [
  // half board attribute option
  [
    // @NOTE: IF MULTILINGUAL FIELD, WE EXPECT VALUE IS ARRAY; ELSE STRING
    // title
    'title' => [
      'default' => 'Half Board',
      'fi' => 'Puolihoito',
      'de' => 'Halbpension'
    ],
    // attribute parent passed as PARENT TITLE
    'parent' => 'Accommodation'

  ],
  // full board attribute option
  [
    // title
    'title' => [
      'default' => 'Full Board',
      'fi' => 'Täysihoito',
      'de' => 'Vollpension'
    ],
    // attribute parent passed as PARENT ID
    'parent' => 3345 // accomodation

  ],
  // cotton attribute option
  [
    // title
    'title' => [
      'default' => 'Cotton',
      'fi' => 'Puuvilla',
      'de' => 'Baumwolle'
    ],
    // attribute parent passed as PARENT TITLE
    'parent' => 'Material'


  ],
];
// IMPORT OPTIONS
// not passing any in this example

/** @var array $importResult */
$importResult = $padloper->import($importItems, 'attribute_options');
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