Skip to content

Commit 9f287b1

Browse files
author
Willy
committed
API-410: Add doc for php client about creating product model
1 parent 293faa9 commit 9f287b1

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

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)