Skip to content

Commit c7e964b

Browse files
LaurentPetardNolwennP
authored andcommitted
PIM-7986: Add reference entity record resources
1 parent 67b8823 commit c7e964b

File tree

2 files changed

+139
-2
lines changed

2 files changed

+139
-2
lines changed
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
### Reference entity record
2+
3+
::: warning
4+
This resource is only available in the [Entreprise Edition](https://www.akeneo.com/enterprise-edition/).
5+
:::
6+
7+
#### Get a record of a given 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' => 'kartell',
16+
* 'values' => [
17+
* 'labels' => [
18+
* [
19+
* 'locale' => 'en_US',
20+
* 'channel' => null,
21+
* 'data' => 'Kartell',
22+
* ],
23+
* ],
24+
* 'image' => [
25+
* [
26+
* 'locale' => null,
27+
* 'channel' => null,
28+
* 'data' => '0/c/b/0/0cb0c0e115dedba676f8d1ad8343ec207ab54c7b_image.jpg',
29+
* ],
30+
* ],
31+
* 'description' => [
32+
* [
33+
* 'locale' => 'en_US',
34+
* 'channel' => null,
35+
* 'data' => 'Kartell, the Italian furniture company that sells modern and remarkable pieces of furnitures.',
36+
* ],
37+
* [
38+
* 'locale' => 'fr_FR',
39+
* 'channel' => null,
40+
* 'data' => 'Kartell, l\'éditeur de meuble italien spécialisé dans la signature de belle pièces au design contemporain.',
41+
* ],
42+
* ],
43+
* 'designer' => [
44+
* [
45+
* 'locale' => null,
46+
* 'channel' => null,
47+
* 'data' => 'starck',
48+
* ],
49+
* ],
50+
* ],
51+
* ];
52+
*
53+
*/
54+
$referenceEntityRecord = $client->getReferenceEntityRecordApi()->get('brand', 'kartell');
55+
```
56+
57+
#### Get the list of the records of a reference entity
58+
59+
Records are automatically paginated and can be filtered.
60+
61+
You can get more information about the available query parameters [here](/api-reference.html#get_reference_entity_records).
62+
63+
```php
64+
$client = new \Akeneo\PimEnterprise\ApiClient\AkeneoPimEnterpriseClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
65+
66+
$referenceEntityRecordsCursor = $client->getReferenceEntityRecordApi()->all('brand');
67+
```
68+
69+
#### Upsert a record of a given reference entity
70+
71+
If the record does not exist yet, this method creates it, otherwise it updates it.
72+
73+
```php
74+
$client = new \Akeneo\PimEnterprise\ApiClient\AkeneoPimEnterpriseClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
75+
76+
$client->getReferenceEntityRecordApi()->upsert('brand', 'kartell', [
77+
'code' => 'kartell',
78+
'values' => [
79+
'label' => [
80+
[
81+
'channel' => null,
82+
'locale' => 'en_US',
83+
'data' => 'Kartell'
84+
],
85+
],
86+
'designer' => [
87+
[
88+
'locale' => null,
89+
'channel' => null,
90+
'data' => 'starck',
91+
],
92+
],
93+
]
94+
]);
95+
```
96+
97+
#### Upsert a list of records of a given reference entity
98+
99+
This method allows to create or update a list of records of a given reference entity.
100+
It has the same behavior as the `upsert` method for a single record.
101+
102+
```php
103+
$client = new \Akeneo\PimEnterprise\ApiClient\AkeneoPimEnterpriseClientBuilder('http://akeneo.com/')->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
104+
105+
$client->getReferenceEntityRecordApi()->upsertList('brand', [
106+
[
107+
'code' => 'kartell',
108+
'values' => [
109+
'label' => [
110+
[
111+
'channel' => null,
112+
'locale' => 'fr_FR',
113+
'data' => 'Kartell'
114+
],
115+
]
116+
]
117+
],
118+
[
119+
'code' => 'lexon',
120+
'values' => [
121+
'label' => [
122+
[
123+
'channel' => null,
124+
'locale' => 'en_US',
125+
'data' => 'Lexon'
126+
],
127+
]
128+
]
129+
]
130+
]);
131+
```

tasks/client-documentation.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,14 @@ gulp.task('create-PAM-md', function () {
7777
.pipe(insert.prepend('## PAM\n'))
7878
.pipe(gulp.dest('tmp/php-client-resources/'));
7979
});
80-
gulp.task('create-resources-md', ['create-products-md','create-catalog-structure-md', 'create-target-market-settings-md', 'create-PAM-md'], function () {
81-
return gulp.src(['tmp/php-client-resources/products.md', 'tmp/php-client-resources/catalog-structure.md', 'tmp/php-client-resources/target-market-settings.md', 'tmp/php-client-resources/PAM.md'])
80+
gulp.task('create-reference-entity-md', function () {
81+
return gulp.src(['content/php-client/resources/reference-entity/*.md'])
82+
.pipe(concat('reference-entity.md'))
83+
.pipe(insert.prepend('## Reference entities\n'))
84+
.pipe(gulp.dest('tmp/php-client-resources/'));
85+
});
86+
gulp.task('create-resources-md', ['create-products-md','create-catalog-structure-md', 'create-target-market-settings-md', 'create-PAM-md', 'create-reference-entity-md'], function () {
87+
return gulp.src(['tmp/php-client-resources/products.md', 'tmp/php-client-resources/catalog-structure.md', 'tmp/php-client-resources/target-market-settings.md', 'tmp/php-client-resources/PAM.md', 'tmp/php-client-resources/reference-entity.md'])
8288
.pipe(concat('resources.md'))
8389
.pipe(insert.prepend('# Resources\n'))
8490
.pipe(gulp.dest('tmp/php-client'));

0 commit comments

Comments
 (0)