Skip to content

Commit ac773b4

Browse files
authored
Merge pull request #645 from akeneo/API-1860
PHP client product UUID update
2 parents 2cdc91d + 2c91c57 commit ac773b4

File tree

6 files changed

+436
-10
lines changed

6 files changed

+436
-10
lines changed

content/php-client/exception.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ You can get the request and the response that are responsible for this exception
1111

1212
```php
1313
try {
14-
$client->getProductApi()->get('top');
14+
$client->getProductUuidApi()->get('1cf1d135-26fe-4ac2-9cf5-cdb69ada0547');
1515
} catch (HttpException $e) {
1616
// do your stuff with the exception
1717
$requestBody = $e->getRequest()->getBody();
@@ -80,7 +80,7 @@ It returns an empty array if there is no error in the array.
8080

8181
```php
8282
try {
83-
$client->getProductApi()->create('top');
83+
$client->getProductUuidApi()->create('1cf1d135-26fe-4ac2-9cf5-cdb69ada0547');
8484
} catch (UnprocessableEntityHttpException $e) {
8585
// do your stuff with the exception
8686
$requestBody = $e->getRequest()->getBody();
@@ -103,7 +103,7 @@ It corresponds to the HTTP code 429.
103103

104104
```php
105105
try {
106-
$client->getProductApi()->get('top');
106+
$client->getProductUuidApi()->get('1cf1d135-26fe-4ac2-9cf5-cdb69ada0547');
107107
} catch (TooManyRequestsHttpException $e) {
108108
$requestBody = $e->getRequest()->getBody();
109109
$responseBody = $e->getResponse()->getBody();

content/php-client/getting-started.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ Want to know more about authentication? It's over [there](/php-client/authentica
8787
Getting a product is as simple as:
8888

8989
```
90-
$product = $client->getProductApi()->get('top');
91-
echo $product['identifier'];
90+
$product = $client->getProductUuidApi()->get('1cf1d135-26fe-4ac2-9cf5-cdb69ada0547');
91+
echo $product['uuid'];
9292
```
9393

9494
Want to [update an attribute](/php-client/resources.html#upsert-an-attribute), [create a category](/php-client/resources.html#create-a-category) or [delete a product](/php-client/resources.html#delete-a-product)? You can get code snippets for all the resources [here](/php-client/resources.html)

content/php-client/list-resources.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ You can define the first parameter `page size` to adjust the number of resources
1616

1717
```php
1818

19-
$products = $client->getProductApi()->all(50);
19+
$products = $client->getProductUuidApi()->all(50);
2020
foreach ($products as $product) {
2121
// do your stuff here
22-
echo $product['identifier'];
22+
echo $product['uuid'];
2323
}
2424
```
2525

@@ -39,7 +39,7 @@ This method allows to get a list of resources page per page, as a classical pagi
3939
You get the first page by calling the function `listPerpage`. The first parameter `limit` is the number of elements per page.
4040

4141
```php
42-
$firstPage = $client->getProductApi()->listPerPage(50);
42+
$firstPage = $client->getProductUuidApi()->listPerPage(50);
4343
```
4444

4545
::: warning
@@ -50,7 +50,7 @@ Then, you can iterate the items of this page:
5050
```php
5151
foreach ($firstPage->getItems() as $product) {
5252
// do your stuff here
53-
echo $product['identifier'];
53+
echo $product['uuid'];
5454
}
5555
```
5656

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
### Product draft UUID
2+
3+
::: info
4+
The following endpoints are largely the same as for [products](/php-client/resources.html#products-draft). The difference? Here, you can query or drafts identified by their uuid. More information [here](/content/getting-started/from-identifiers-to-uuid-7x/welcome.md).
5+
:::
6+
7+
#### Get a product draft
8+
::: php-client-availability versions=10.0
9+
10+
```php
11+
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
12+
13+
/*
14+
* Returns an array like this:
15+
* [
16+
* 'uuid' => '12951d98-210e-4bRC-ab18-7fdgf1bd14f3',
17+
* 'enabled' => true,
18+
* 'family' => 'tshirt',
19+
* 'categories' => ['summer_collection'],
20+
* 'groups' => [],
21+
* 'values' => [
22+
* 'sku' => [
23+
* [
24+
* 'locale' => null,
25+
* 'scope' => null,
26+
* 'data' => 'top'
27+
* ]
28+
* ],
29+
* 'name' => [
30+
* [
31+
* 'data' => 'Top',
32+
* 'locale' => 'en_US',
33+
* 'scope' => null
34+
* ],
35+
* [
36+
* 'data' => 'Débardeur',
37+
* 'locale' => 'fr_FR',
38+
* 'scope' => null
39+
* ],
40+
* ],
41+
* ],
42+
* 'created' => '2016-06-23T18:24:44+02:00',
43+
* 'updated' => '2016-06-25T17:56:12+02:00',
44+
* 'associations' => [
45+
* 'PACK' => [
46+
* 'products' => [
47+
* 'sunglass'
48+
* ],
49+
* 'groups' => [],
50+
* 'product_models' => []
51+
* ],
52+
* ],
53+
* 'quantified_associations' => [
54+
* 'PRODUCT_SET' => [
55+
* 'products' => [
56+
* ['uuid' => '5719e119-613c-49af-9244-fa39a9e0cb1d', 'quantity' => 2],
57+
* ],
58+
* 'product_models' => [],
59+
* ],
60+
* ],
61+
* 'metadata' => [
62+
* 'workflow_status' => 'draft_in_progress',
63+
* ],
64+
* ]
65+
*/
66+
$draftProduct = $client->getProductDraftUuidApi()->get('12951d98-210e-4bRC-ab18-7fdgf1bd14f3');
67+
```
68+
69+
You can get more information about the returned format of the product values [here](/concepts/products.html#focus-on-the-product-values).
70+
71+
The field `metadata` is specific to Akeneo PIM Enterprise Edition. The status of the draft is specified in this field.
72+
73+
#### Submit a product draft for approval
74+
::: php-client-availability versions=10.0
75+
76+
```php
77+
$client = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
78+
79+
$client->getProductDraftUuidApi()->submitForApproval('12951d98-210e-4bRC-ab18-7fdgf1bd14f3');
80+
```
81+
82+
It is mandatory that the user already created a draft for this product, and that this draft was not approved yet.

0 commit comments

Comments
 (0)