akeneo / api-php-client

PHP client of Akeneo PIM API

Home Page:https://packagist.org/packages/akeneo/api-php-client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to set product weight

tekhoi opened this issue · comments

Updating a metric attribute (weight) with the following isn't working, am I missing something? The existing value gets removed but no new value is set.

'product_weight' => [ [ 'data' => [ [ 'amount' => '20', 'unit' => 'POUND', ], ], 'locale' => null, 'scope' => null, ], ],

@tekhoi for me the following function works to update a metric attribute:

function setAttributeValue_product_metric($sku, $attribute, $amount, $unit)
{
    global $api;

    $api->getProductApi()->upsertList(
        [
            [
                'identifier' => $sku,
                "values" => [
                    $attribute => [
                        [
                            'data' => [
                                'amount' => $amount,
                                'unit'   => $unit,
                            ],
                            'locale' => null,
                            'scope' => null,
                        ],
                    ],
                ],
            ],
        ]);
}

Does this function work for you as well?

The issue might be related to an older version of the PIM, but since there's no answer, closing.
Thank you @timonburkard for the working example snippet.