@@ -28,6 +28,48 @@ $client = new \Akeneo\Pim\AkeneoPimClientBuilder('http://akeneo.com/')->buildAut
28
28
$productModel = $client->getProductModelApi()->get('rain_boots_red');
29
29
```
30
30
31
+ ### Get a list of product models
32
+
33
+ There are two ways of getting product models.
34
+
35
+ #### By getting pages
36
+
37
+ This method allows to get product models page per page, as a classical pagination.
38
+ It's possible to get the total number of product models with this method.
39
+
40
+ ``` php
41
+ $client = new \Akeneo\Pim\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
42
+
43
+ $firstPage = $client->getProductModelApi()->listPerPage(50, true);
44
+ ```
45
+
46
+ ::: warning
47
+ There is a maximum limit allowed on server side for the parameter ` limit ` .
48
+ :::
49
+
50
+ ::: warning
51
+ Setting the parameter ` with_count ` to ` true ` can drastically decrease the performance.
52
+ 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.
53
+ :::
54
+
55
+ You can get more information about this method [ here] ( /php-client/list-resources.html#by-getting-pages ) .
56
+
57
+ #### With a cursor
58
+
59
+ This method allows to iterate the product models. It will automatically get the next pages for you.
60
+
61
+ ``` php
62
+ $client = new \Akeneo\Pim\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
63
+
64
+ $productModels = $client->getProductModelApi()->all(50);
65
+ ```
66
+
67
+ ::: warning
68
+ There is a maximum limit allowed on server side for the parameter ` pageSize ` .
69
+ :::
70
+
71
+ You can get more information about this method [ here] ( /php-client/list-resources.html#with-a-cursor ) .
72
+
31
73
### Create a product model
32
74
33
75
If the product model does not exist yet, this method creates it, otherwise it throws an exception.
@@ -60,44 +102,61 @@ $client->getProductModelApi()->create('saddle_rain_boots', [
60
102
61
103
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
104
63
- ### Get a list of product models
64
-
65
- There are two ways of getting product models.
66
-
67
- #### By getting pages
105
+ ### Upsert a product model
68
106
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.
107
+ If the product model does not exist yet, this method creates it, otherwise it updates it.
71
108
72
109
``` php
73
110
$client = new \Akeneo\Pim\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
74
111
75
- $firstPage = $client->getProductModelApi()->listPerPage(50, true);
112
+ $client->getProductModelApi()->upsert('rain_boots_red', [
113
+ 'categories' => ['2014_collection', 'winter_boots']
114
+ ]);
76
115
```
77
116
78
- ::: warning
79
- There is a maximum limit allowed on server side for the parameter ` limit ` .
80
- :::
117
+ ### Upsert a list of product models
81
118
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
- :::
119
+ This method allows to create or update a list of product models.
120
+ It has the same behavior as the ` upsert ` method for a single product model, except that the code must be specified in the data of each product models.
86
121
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
122
93
123
``` php
94
124
$client = new \Akeneo\Pim\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
95
125
96
- $productModels = $client->getProductModelApi()->all(50);
126
+ $responseLines = $client->getProductModelApi()->upsertList([
127
+ [
128
+ 'code' => 'rain_boots_red',
129
+ 'family_variant' => 'rain_boots_color_size',
130
+ 'parent' => 'rain_boots',
131
+ 'categories' => ['2014_collection', 'winter_boots']
132
+ ],
133
+ [
134
+ 'code' => 'rain_boots_saddle',
135
+ 'family_variant' => 'rain_boots_color_size',
136
+ 'parent' => 'rain_boots',
137
+ 'categories' => ['2014_collection', 'winter_boots'],
138
+ 'values' => [
139
+ 'description' => [
140
+ [
141
+ 'locale' => 'en_US',
142
+ 'scope' => 'ecommerce',
143
+ 'data' => 'Saddle rain boots made of rubber for winter.'
144
+ ]
145
+ ]
146
+ ]
147
+ ]
148
+ ]);
149
+
150
+ foreach ($responseLines as $line) {
151
+ echo $line['line'];
152
+ echo $line['identifier'];
153
+ echo $line['status_code'];
154
+ if (isset($line['message'])) {
155
+ echo $line['message'];
156
+ }
157
+ }
97
158
```
98
159
99
- ::: warning
100
- There is a maximum limit allowed on server side for the parameter ` pageSize ` .
160
+ ::: warning
161
+ There is a limit on the maximum number of product models that you can upsert in one time on server side. By default this limit is set to 100 .
101
162
:::
102
-
103
- You can get more information about this method [ here] ( /php-client/list-resources.html#with-a-cursor ) .
0 commit comments