Skip to content

Commit 09bf779

Browse files
Merge pull request #140 from akeneo/patch-2.0.4
Merge API-406 / 410 / 409 in master
2 parents dfc6770 + fc69689 commit 09bf779

File tree

2 files changed

+203
-0
lines changed

2 files changed

+203
-0
lines changed
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
## Family variants
2+
3+
### Get a family variant
4+
5+
```php
6+
$client = new \Akeneo\Pim\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
7+
8+
/*
9+
* Returns an array like this:
10+
* [
11+
* 'code' => 'boots_color_size',
12+
* 'labels' => [
13+
* 'de_DE' => 'Stiefel nach Farbe und Größe',
14+
* 'en_US' => 'Boots by color and size',
15+
* 'fr_FR' => 'Bottes par couleur et taille'
16+
* ],
17+
* 'variant_attribute_sets' => [
18+
* [
19+
* 'level' => 1,
20+
* 'axes' => ['color'],
21+
* 'attributes' => ['name', 'description', 'color']
22+
* ],
23+
* [
24+
* 'level' => 2,
25+
* 'axes' => ['size'],
26+
* 'attributes' => ['sku', 'size']
27+
* ]
28+
* ]
29+
* ]
30+
*/
31+
$familyVariant = $client->getFamilyVariantApi()->get('boots', 'boots_color_size');
32+
```
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+
```
59+
60+
### Get a list of family variants
61+
62+
There are two ways of getting family variants.
63+
64+
#### By getting pages
65+
66+
This method allows to get family variants page per page, as a classical pagination.
67+
It's possible to get the total number of family variants with this method.
68+
69+
```php
70+
$client = new \Akeneo\Pim\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
71+
72+
$firstPage = $client->getFamilyVariantApi()->listPerPage('boots', 50, true);
73+
```
74+
75+
::: warning
76+
There is a maximum limit allowed on server side for the parameter `limit`.
77+
:::
78+
79+
::: warning
80+
Setting the parameter `with_count` to `true` can drastically decrease the performance.
81+
It's recommended to let this parameter with the default value `false` if the total number of family variants is not needed in the response.
82+
:::
83+
84+
You can get more information about this method [here](/php-client/list-resources.html#by-getting-pages).
85+
86+
#### With a cursor
87+
88+
This method allows to iterate the family variants. It will automatically get the next pages for you.
89+
90+
```php
91+
$client = new \Akeneo\Pim\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
92+
93+
$familyVariants = $client->getFamilyVariantApi()->all('boots', 50);
94+
```
95+
96+
:::warning
97+
There is a maximum limit allowed on server side for the parameter `pageSize`.
98+
:::
99+
100+
You can get more information about this method [here](/php-client/list-resources.html#with-a-cursor).
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
## Product models
2+
3+
### Get a product model
4+
5+
```php
6+
$client = new \Akeneo\Pim\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
7+
8+
/*
9+
* Returns an array like this:
10+
* [
11+
* 'code' => 'rain_boots_red',
12+
* 'family_variant' => 'boots_color_size',
13+
* 'parent' => 'rain_boots',
14+
* 'categories' => ['2014_collection', 'winter_collection', 'winter_boots'],
15+
* 'values' => [
16+
* 'name' => [
17+
* [
18+
* 'locale' => 'en_US',
19+
* 'scope' => null,
20+
* 'data' => 'Red rain boots',
21+
* ]
22+
* ],
23+
* ],
24+
* 'created' => '2017-10-17T14:12:35+00:00',
25+
* 'updated' => '2017-10-17T14:12:35+00:00'
26+
* ]
27+
*/
28+
$productModel = $client->getProductModelApi()->get('rain_boots_red');
29+
```
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).
62+
63+
### Get a list of product models
64+
65+
There are two ways of getting product models.
66+
67+
#### By getting pages
68+
69+
This method allows to get product models page per page, as a classical pagination.
70+
It's possible to get the total number of product models with this method.
71+
72+
```php
73+
$client = new \Akeneo\Pim\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
74+
75+
$firstPage = $client->getProductModelApi()->listPerPage(50, true);
76+
```
77+
78+
::: warning
79+
There is a maximum limit allowed on server side for the parameter `limit`.
80+
:::
81+
82+
::: warning
83+
Setting the parameter `with_count` to `true` can drastically decrease the performance.
84+
It's recommended to let this parameter with the default value `false` if the total number of product models is not needed in the response.
85+
:::
86+
87+
You can get more information about this method [here](/php-client/list-resources.html#by-getting-pages).
88+
89+
#### With a cursor
90+
91+
This method allows to iterate the product models. It will automatically get the next pages for you.
92+
93+
```php
94+
$client = new \Akeneo\Pim\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
95+
96+
$productModels = $client->getProductModelApi()->all(50);
97+
```
98+
99+
:::warning
100+
There is a maximum limit allowed on server side for the parameter `pageSize`.
101+
:::
102+
103+
You can get more information about this method [here](/php-client/list-resources.html#with-a-cursor).

0 commit comments

Comments
 (0)