2016-10-10 16 views
1

REST APIを使用して顧客のEAV属性を更新/追加するにはどうすればよいですか?Magento 2.1顧客カスタムEAV属性をREST APIで更新する

私はこのURL身体データとして

http://<website>/rest/V1/customers/1 

そして、これと[PUT] /V1/customers/{id}を使用して、それを実行しようとしました:

$data = array(
    'customer' => array(
     'id' => 1, 
     'email' => '[email protected]', 
     'firstname' => 'John', 
     'lastname' => 'Doe', 
     'website_id' => 1, 
     'custom_attributes' => array(
      'attribute_code' => 'my_custom_attribute_code', 
      'value' => 'my_custom_attribute_value' 
     ) 
    ) 
); 

私は、このようなfirstnameとして顧客のデフォルト属性を編集することができましたし、 lastname私はEAV属性を編集することができませんでした。

デフォルトのcustomerCustomerRepositoryV1インターフェイスで行うことはできますか? そうでなければ、顧客のEAV属性を編集/追加できるようにどのように拡張しますか?

ありがとうございます。

Magentoの2.1休憩APIインタフェース: http://devdocs.magento.com/swagger

答えて

0

身体データに誤りがありました。私はインデックスをcustom_attributes配列に置くのを忘れていました。

それはこのようになっている必要があります。

$data = array(
    'customer' => array(
     'id' => 1, 
     'email' => '[email protected]', 
     'firstname' => 'John', 
     'lastname' => 'Doe', 
     'website_id' => 1, 
     'custom_attributes' => array(
      '0' => array(
       'attribute_code' => 'my_custom_attribute_code', 
       'value' => 'my_custom_attribute_value' 
      ) 
     ) 
    ) 
); 
関連する問題