Skip to content

Commit d3c65d2

Browse files
Willyahocquard
authored andcommitted
API-412-413: Upsert and Upsert list family variants PHP client
1 parent 09bf779 commit d3c65d2

File tree

2 files changed

+61
-2
lines changed

2 files changed

+61
-2
lines changed

content/php-client/resources/families.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ $client->getFamilyApi()->create('caps', [
7474
]);
7575
```
7676

77-
78-
7977
### Upsert a family
8078

8179
If the family does not exist yet, this method creates it, otherwise it updates it.

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

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,64 @@ There is a maximum limit allowed on server side for the parameter `pageSize`.
9898
:::
9999

100100
You can get more information about this method [here](/php-client/list-resources.html#with-a-cursor).
101+
102+
### Upsert a family variant
103+
104+
If the family variant does not exist yet, this method creates it, otherwise it updates it.
105+
106+
```php
107+
$client = new \Akeneo\Pim\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
108+
109+
$client->getFamilyVariantApi()->upsert('boots', [
110+
'code' => 'rain_boots_color_size',
111+
'labels' => [
112+
'de_DE' => 'Stiefel nach Farbe und Größe',
113+
'en_US' => 'Updating label',
114+
'fr_FR' => 'Mise à jour du label'
115+
]
116+
]);
117+
```
118+
119+
### Upsert a list of family variants
120+
121+
This method allows to create or update a list of family variants.
122+
It has the same behavior as the `upsert` method for a single family variant, except that the code must be specified in the data of each family variant.
123+
124+
125+
```php
126+
$client = new \Akeneo\Pim\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
127+
128+
$responseLines = $client->getFamilyVariantApi()->upsertList('boots', [
129+
[
130+
'code' => 'rain_boots_color_size',
131+
'labels' => [
132+
'de_DE' => 'Stiefel nach Farbe und Größe',
133+
'en_US' => 'Updating label',
134+
'fr_FR' => 'Mise à jour du label'
135+
]
136+
],
137+
[
138+
'code' => 'man_boots_color_size',
139+
'labels' => [
140+
'de_DE' => 'Stiefel nach Farbe und Größe',
141+
'en_US' => 'Updating label',
142+
'fr_FR' => 'Mise à jour du label'
143+
]
144+
]
145+
]);
146+
147+
foreach ($responseLines as $line) {
148+
echo $line['line'];
149+
echo $line['identifier'];
150+
echo $line['status_code'];
151+
if (isset($line['message'])) {
152+
echo $line['message'];
153+
}
154+
}
155+
```
156+
157+
::: warning
158+
There is a limit on the maximum number of family variants that you can upsert in one time on server side. By default this limit is set to 100.
159+
:::
160+
161+
You can get a complete description of the expected format and the returned format [here](/api-reference.html#get_families__family_code__variants).

0 commit comments

Comments
 (0)