0
我試圖弄清楚如何在我請求後編輯訂單。 我做了一個自定義屬性,無論是否導出訂單。Magento 2 Rest API訂單編輯
我首先獲取所有狀態未導出的訂單,並在導出它們之後,我想將自定義屬性更改爲導出。
什麼是REST請求編輯/更新訂單?我不斷收到類似的錯誤消息:
{"message":"%fieldName is a required field.","parameters":
{"fieldName":"entity"}
這是我的代碼:
$json = array(
"entity_id" => $id,
"extension_attributes" => array(
"custom_export_attribute" => "exported",
)
);
$webapi = new ApiClient('https://dev.local.nl', self::$username, self::$password);
$response = $webapi->getClient()->request('PUT', '/rest/V1/orders/create', [
'headers' => [
'Authorization' => "Bearer " . $webapi->getToken(),
'Content-Type' => "application/json"
],
'body' => json_encode($json)
]);
return json_decode($response->getBody(), true);
我也試過:
$webapi->getClient()->request('PUT', '/rest/V1/orders/'.$id,