Skip to content

Commit 9023956

Browse files
authored
API-1943 reviews (#715)
* feat(API-1943): Add tabs to snippets * feat(API-1943): Rename endpoint badge
1 parent de278ab commit 9023956

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

content/tutorials/guides/how-to-get-pim-product-information.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
<div class="endpoint-container">
3232
<div class="endpoint-text">REST API endpoint(s):</div>
33-
<a href="/api-reference.html#get_products_uuid" class="endpoint-link" target="_blank" rel="noopener noreferrer">product-uuid</a>
33+
<a href="/api-reference.html#get_products_uuid" class="endpoint-link" target="_blank" rel="noopener noreferrer">products</a>
3434
</div>
3535

3636
<div class="block-requirements">
@@ -84,7 +84,7 @@ This `data` field is composed of the product information you want to extract. Th
8484
In a nutshell:
8585

8686
<!-- todo find the right language for comments highlight -->
87-
```php
87+
```php [activate:PHP]
8888

8989
{
9090
"values": { # Contains all the product values, stored in associative arrays
@@ -119,7 +119,7 @@ In a nutshell:
119119

120120
### 0 - Initialization
121121

122-
```php
122+
```php [activate:PHP]
123123

124124
function buildApiClient(): GuzzleHttp\Client
125125
{
@@ -165,7 +165,7 @@ Have a look at other [product filters](/documentation/filter.html#filter-on-prod
165165

166166
Collect only the products you need with the help of the family code list you built in the guided tutorial “How to get families, family variants, and attributes” and your locales and channel that you extracted during the guided tutorial “How to retrieve PIM structure”.
167167

168-
```php
168+
```php [activate:PHP]
169169

170170
function fetchProducts(): array
171171
{
@@ -218,7 +218,7 @@ function fetchProducts(): array
218218

219219
Call the product endpoint with these minimum filters.
220220

221-
```php
221+
```php [activate:PHP]
222222

223223
function fetchProducts(): array
224224
{
@@ -262,7 +262,7 @@ In the guided tutorial **How to get families and attribute**, we have stored an
262262

263263
Simply search your attribute in the **attribute_list**.
264264

265-
```php
265+
```php [activate:PHP]
266266

267267
function findAttributeTypeInAttributeList(string $attributeCode, array $attributeList): string
268268
{
@@ -278,7 +278,7 @@ Simply get the attribute type by requesting the API. Instructions [here](/tutori
278278

279279
Parse `data` properties according to the attribute type you got in the previous step.
280280

281-
```php
281+
```php [activate:PHP]
282282

283283
const PIM_CATALOG_IDENTIFIER = 'pim_catalog_identifier';
284284
const PIM_CATALOG_TEXT = 'pim_catalog_text';
@@ -389,7 +389,7 @@ function extractData(string $attributeType, array $value): string|bool
389389
```
390390

391391
Iterate over products to parse their value list one by one:
392-
```php
392+
```php [activate:PHP]
393393

394394
$products = fetchProducts();
395395
$attributes = getAttributes();
@@ -409,7 +409,8 @@ foreach ($products as $key => $product) {
409409
storeProducts($products);
410410
```
411411

412-
```php
412+
Example output:
413+
```php [activate:PHP]
413414

414415
var_export($products);
415416

@@ -463,7 +464,7 @@ Disclaimer: The previous snippet doesn’t handle for now the following attribut
463464
Is your attribute type **pim_catalog_file** or **pim_catalog_image** ?
464465
It means you are looking at media that can be downloaded. To proceed, simply call the “product media file” API endpoint.
465466

466-
```php
467+
```php [activate:PHP]
467468

468469
function fetchProductMediaFileResources(array $productMediaFileValues): array
469470
{
@@ -485,7 +486,7 @@ function fetchProductMediaFileResources(array $productMediaFileValues): array
485486
```
486487

487488
Update the previous script from step 2.2 so media files are fetched in the same loop:
488-
```php
489+
```php [activate:PHP]
489490

490491
$products = fetchProducts();
491492
$attributes = getAttributes();
@@ -513,7 +514,8 @@ saveProducts($products);
513514
saveMediaFiles($productMediaFileResources);
514515
```
515516

516-
```php
517+
Example output:
518+
```php [activate:PHP]
517519

518520
var_export($productMediaFileResources);
519521

0 commit comments

Comments
 (0)