-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
seeing the response of any upsertList() call #176
Comments
I agree, it does not work on my side as well. I tried the following, which updates the product values correctly. However, I am not getting an output with the suggested $responseLines = $api->getProductApi()->upsertList(
[
[
'identifier' => 'TCK-171',
"values" => [
'Mar_StatusComment' => [
[
'data' => "Test 123",
'locale' => 'en_US',
'scope' => null,
],
],
],
],
[
'identifier' => 'TCK-170',
"values" => [
'Mar_StatusComment' => [
[
'data' => "Test 12345",
'locale' => 'en_US',
'scope' => null,
],
],
],
]
]);
foreach ($responseLines as $line) {
echo $line['line'];
echo $line['identifier'];
echo $line['status_code'];
if (isset($line['message'])) {
echo $line['message'];
}
} |
Hi @johamm @timonburkard , @timonburkard What's the output if you do array(3) {
'line' =>
int(1)
'identifier' =>
string(8) "TCK-171"
'status_code' =>
int(204) // 201 if created, 204 if updated
} And example if any line produces an error array(5) {
'line' =>
int(2)
'identifier' =>
string(7) "noexist"
'status_code' =>
int(422)
'message' =>
string(106) "The descriptions attribute does not exist in your PIM. Check the expected format on the API documentation."
'_links' =>
array(1) {
'documentation' =>
array(1) {
'href' =>
string(62) "http://api.akeneo.com/api-reference.html#patch_products__code_"
}
}
} So it seems ok my end with client v7 to v9, on a PIM v6. |
Hi @LevFlavien, Thanks for your reply. I tried your suggestion as follows: $responseLines = $api->getProductApi()->upsertList(
[
[
'identifier' => 'TCK-171',
"values" => [
'Mar_StatusComment' => [
[
'data' => "Test 2022-02-24",
'locale' => 'en_US',
'scope' => null,
],
],
],
],
[
'identifier' => 'TCK-170',
"values" => [
'Mar_StatusComment' => [
[
'data' => "Test 2022-02-24",
'locale' => 'en_US',
'scope' => null,
],
],
],
]
]);
print("*** responesLines ***\n");
var_dump($responseLines);
print("\n\n");
$i = 0;
foreach ($responseLines as $line) {
print("*** line: " . $i . " ***\n");
var_dump($line);
print("\n\n");
++$i;
} The products are updated correctly: However, I still cannot iterate properly through the response. Output on console:
I also checked composer to ensure I am on the latest version:
My PIM version is EE v6.0.21. |
Weird, it works on my side with the same PIM version. Could you please check whether the problem is on PIM or Client side, by requesting without using the client? For example here's a curl, complete curl -X PATCH <PIM_URL>api/rest/v1/products \
-H "Content-Type: application/vnd.akeneo.collection+json" \
-H "Authorization: Bearer <YOUR_TOKEN>" \
-d $'{"identifier": "TCK-171", "values": {"Mar_StatusComment": [{"data": "Test 2022-02-24", "locale": "en_US", "scope": null}]}}\n{"identifier": "TCK-170", "values": {"Mar_StatusComment": [{"data": "Test 2022-02-24", "locale": "en_US", "scope": null}]}}' expected output: {"line":1,"identifier":"TCK-171","status_code":204}
{"line":2,"identifier":"TCK-170","status_code":204} |
@LevFlavien it works with curl: |
I'm using upsertList() in a number of areas (ProductModel, Category, AttributeOptions etc) and when I run it, I'm not getting a response. How would I know what item has been created/updated successfully and which have failed? Reading the API documentation suggests you should...
For example: https://api.akeneo.com/php-client/resources.html#upsert-a-list-of-product-models
When I try this, there's nothing showing. When I print_r($responseLines) there's only the following:
The text was updated successfully, but these errors were encountered: