Skip to content

Commit 6a00e09

Browse files
author
Willy Mesnage
authored
Merge pull request #128 from akeneo/API-410
API-410: Add doc for php client about family variant and product model creation
2 parents 474e1af + 9f287b1 commit 6a00e09

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

content/php-client/resources/family-variants.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,29 @@ $client = new \Akeneo\Pim\AkeneoPimClientBuilder('http://akeneo.com/')->buildAut
3030
*/
3131
$familyVariant = $client->getFamilyVariantApi()->get('boots', 'boots_color_size');
3232
```
33+
34+
### Create a family variant
35+
36+
If the family variant does not exist yet, this method creates it, otherwise it throws an exception.
37+
38+
```php
39+
$client = new \Akeneo\Pim\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
40+
41+
$client->getFamilyVariantApi()->create('boots', 'boots_size_color', [
42+
'labels' => [
43+
'en_US' => 'Boots by color and size'
44+
],
45+
'variant_attribute_sets' => [
46+
[
47+
'level' => 1,
48+
'axes' => ['size'],
49+
'attributes' => ['name', 'description', 'size']
50+
],
51+
[
52+
'level' => 2,
53+
'axes' => ['color'],
54+
'attributes' => ['sku', 'color']
55+
]
56+
]
57+
]);
58+
```

content/php-client/resources/product-models.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,35 @@ $client = new \Akeneo\Pim\AkeneoPimClientBuilder('http://akeneo.com/')->buildAut
2727
*/
2828
$productModel = $client->getProductModelApi()->get('rain_boots_red');
2929
```
30+
31+
### Create a product model
32+
33+
If the product model does not exist yet, this method creates it, otherwise it throws an exception.
34+
35+
```php
36+
$client = new \Akeneo\Pim\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
37+
38+
$client->getProductModelApi()->create('saddle_rain_boots', [
39+
'family_variant' => 'boots_color_size',
40+
'parent' => 'rain_boots',
41+
'categories' => ['2014_collection', 'winter_boots', 'winter_collection'],
42+
'values' => [
43+
'name' => [
44+
[
45+
'locale' => 'en_US',
46+
'scope' => null,
47+
'data' => 'Saddle rain boots',
48+
]
49+
],
50+
'color' => [
51+
[
52+
'locale' => null,
53+
'scope' => null,
54+
'data' => 'saddle'
55+
]
56+
]
57+
]
58+
]);
59+
```
60+
61+
Product model values use the same format as the product values. If you want to know more, take a look at [here](/documentation/resources.html#product-values).

0 commit comments

Comments
 (0)