|
| 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 | +``` |
0 commit comments