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.