Skip to content

Commit f400fbe

Browse files
LaurentPetardNolwennP
authored andcommitted
PIM-7761: Add reference entity resource
1 parent 711dba7 commit f400fbe

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
### Reference entity
2+
3+
::: warning
4+
This resource is only available in the [Entreprise Edition](https://www.akeneo.com/enterprise-edition/).
5+
:::
6+
7+
#### Get a reference entity
8+
9+
```php
10+
$client = new \Akeneo\PimEnterprise\ApiClient\AkeneoPimEnterpriseClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
11+
12+
/*
13+
* Returns an array like this:
14+
* [
15+
* 'code' => 'brand',
16+
* 'labels' => [
17+
* 'en_US' => 'Brand',
18+
* 'fr_FR' => 'Marque',
19+
* ],
20+
* 'image' => '5/e/e/e/5eee4242ed8d2f1a5f5ff41d00457ecbe637b71e_brand.jpg',
21+
* '_links' => [
22+
* 'image_download' => [
23+
* 'href' => 'http://localhost:8080/api/rest/v1/reference-entities-media-files/5/e/e/e/5eee4242ed8d2f1a5f5ff41d00457ecbe637b71e_brand.jpg',
24+
* ],
25+
* ],
26+
* ]
27+
*/
28+
$referenceEntity = $client->getReferenceEntityApi()->get('brand');
29+
```
30+
31+
#### Get the list of the reference entities
32+
33+
You can get more information about the available query parameters [here](/api-reference.html#get_reference_entities).
34+
35+
```php
36+
$client = new \Akeneo\PimEnterprise\ApiClient\AkeneoPimEnterpriseClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
37+
38+
$referenceEntitiesCursor = $client->getReferenceEntityApi()->all();
39+
```
40+
41+
#### Upsert a reference entity
42+
43+
If the reference entity does not exist yet, this method creates it, otherwise it updates it.
44+
45+
```php
46+
$client = new \Akeneo\PimEnterprise\ApiClient\AkeneoPimEnterpriseClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
47+
48+
$client->getReferenceEntityApi()->upsert('brand', [
49+
'code' => 'brand',
50+
'labels' => [
51+
'en_US' => 'Brand',
52+
'fr_FR' => 'Marque',
53+
],
54+
'image' => '5/e/e/e/5eee4242ed8d2f1a5f5ff41d00457ecbe637b71e_brand.jpg'
55+
]);
56+
```

tasks/client-documentation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ gulp.task('create-PAM-md', function () {
7878
.pipe(gulp.dest('tmp/php-client-resources/'));
7979
});
8080
gulp.task('create-reference-entity-md', function () {
81-
return gulp.src(['content/php-client/resources/reference-entity/*.md'])
81+
return gulp.src(['content/php-client/resources/reference-entity/reference-entities.md', 'content/php-client/resources/reference-entity/*.md'])
8282
.pipe(concat('reference-entity.md'))
8383
.pipe(insert.prepend('## Reference entities\n'))
8484
.pipe(gulp.dest('tmp/php-client-resources/'));

0 commit comments

Comments
 (0)