Skip to content

Commit 58b00c8

Browse files
author
Samuel Gomis
committed
feat(API-1953): fix
1 parent 40f600a commit 58b00c8

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

content/tutorials/guides/how-to-collect-product-variations.md

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ In the PIM we handle product models and product variations.
6363
![scheme_variants](../../img/tutorials/how-to-collect-product-variations/scheme_variants.png)
6464

6565
::: tips
66-
Before digging into the code you can find out more about these concepts in our [helpcenter](https://help.akeneo.com/pim/serenity/articles/what-about-products-variants.html#about-products-with-variants).
66+
Before digging into the code you can find out more about these concepts in our <a href="https://help.akeneo.com/pim/serenity/articles/what-about-products-variants.html#about-products-with-variants" class="endpoint-link" target="_blank" rel="noopener noreferrer">helpcenter</a>
6767
:::
6868

6969
Here are quick definitions:
@@ -104,17 +104,10 @@ We noticed that many e-commerce solutions understand product variation on only o
104104

105105
```php [activate:PHP]
106106

107-
$pimUrl = 'https://url-of-your-pim.com';
108-
$appToken = 'your_app_token'; // Token provided during oAuth steps
109-
110-
// If you haven't done it yet, please follow the Guzzle official documentation for installing the client
111-
// https://docs.guzzlephp.org/en/stable/overview.html#installation
112-
113-
// Set your client for querying Akeneo API as follows
114107
function buildApiClient(): GuzzleHttp\Client
115108
{
116-
$pimUrl = '<PIM_URL>';
117-
$appToken = '<APP_TOKEN>'; // Token provided during oauth steps
109+
$pimUrl = 'https://url-of-your-pim.com';
110+
$appToken = 'your_app_token'; // Token provided during oAuth steps
118111

119112
// If you haven't done it yet,
120113
// please follow the Guzzle official documentation to install the client
@@ -125,14 +118,15 @@ function buildApiClient(): GuzzleHttp\Client
125118
'headers' => ['Authorization' => 'Bearer ' . $appToken],
126119
]);
127120
}
121+
128122
```
129123

130124
### Use case 1: Collect product variation information - all levels
131125

132126
#### 1. Collect product models
133127
##### 1.1 You are following the App workflow?
134128

135-
In the guided tutorial [**"How to get families and attributes"**](/tutorials/how-to-get-families-and-attributes.html), we have stored a **family_code_list**. It’s time to use it!
129+
In the guided tutorial <a href="/tutorials/how-to-get-families-and-attributes.html" target="_blank" rel="noopener noreferrer">How to get families and attributes</a>, we have stored a **family_code_list**. It’s time to use it!
136130

137131
```php [activate:PHP]
138132

@@ -144,9 +138,11 @@ function getProductModels(): array
144138
$maxFamiliesPerQuery = 3;
145139
$scope = 'ecommerce';
146140

147-
// Get family $codes and locales from storage
141+
// Get family codes from storage
148142
$familyCodes = getFamilyCodes();
149-
$locales = getLocales('fr');
143+
144+
// Get locales from storage
145+
$locales = getLocales();
150146

151147
$familyCodeChunks = array_chunk($familyCodes, $maxFamiliesPerQuery);
152148

@@ -209,12 +205,12 @@ function getProductModels(): array
209205

210206
#### 2. Process product model
211207
##### 2.1. Parse and store the product model
212-
Parse and store a product or a product model is definitely the same thing. Please have a how to our guided tutorial [**"How to get product information"**](/tutorials/how-to-collect-products.html).
208+
Parse and store a product or a product model is definitely the same thing. Please have a how to our guided tutorial <a href="/tutorials/how-to-get-families-and-attributes.html" target="_blank" rel="noopener noreferrer">How to get families and attributes</a>.
213209

214210
##### 2.2. Collect its family variant
215211
###### 2.2.1 You are following the App workflow?
216212

217-
Good news: you already store the family variant in the guided tutorial [**"How to get families and attributes"**](/tutorials/how-to-get-families-and-attributes.html). Go ahead!
213+
Good news: you already store the family variant in the guided tutorial <a href="/tutorials/how-to-get-families-and-attributes.html" target="_blank" rel="noopener noreferrer">How to get families and attributes</a>. Go ahead!
218214

219215
###### 2.2.2 You are not following the App workflow?
220216
Query the API.
@@ -277,9 +273,9 @@ function getProductVariants(): array
277273
$productVariants[] = $data['_embedded']['items'];
278274
}
279275

280-
return array_merge(...$productVariants);
276+
$productVariants = array_merge(...$productVariants);
281277
}
282278

283279
```
284280

285-
Again, treat each product like a simple product. Please refer to the guided tutorial [**“How to get product information”**](/tutorials/how-to-collect-products.html)
281+
Again, treat each product like a simple product. Please refer to the guided tutorial <a href="/tutorials/how-to-get-families-and-attributes.html" target="_blank" rel="noopener noreferrer">How to get families and attributes</a>

0 commit comments

Comments
 (0)