2017-06-20 9 views
1

私はMagento 2の残りのAPIを使用してすべてのカテゴリをリストしています。Magento 2のカスタム属性を持つすべてのカテゴリを取得するREST Api

{{production_url}}/index.phpを/休憩/ V1 /カテゴリ

それはすべてのカテゴリを返します

{ 
    "id": 2, 
    "parent_id": 1, 
    "name": "Default Category", 
    "is_active": true, 
    "position": 1, 
    "level": 1, 
    "product_count": 0, 
    "children_data": [{ 
     "id": 3, 
     "parent_id": 2, 
     "name": "T-shirts", 
     "is_active": true, 
     "position": 1, 
     "level": 2, 
     "product_count": 8, 
     "children_data": [] 
    }, { 
     "id": 4, 
     "parent_id": 2, 
     "name": "Phants", 
     "is_active": true, 
     "position": 2, 
     "level": 2, 
     "product_count": 0, 
     "children_data": [] 
    }, { 
     "id": 5, 
     "parent_id": 2, 
     "name": "Chridar", 
     "is_active": true, 
     "position": 3, 
     "level": 2, 
     "product_count": 0, 
     "children_data": [] 
    }] 
} 

が、私はカスタムは、結果内のすべてのカテゴリの属性を必要としますしかし、今私はカスタム属性を取得するための下のAPIを呼び出す必要があります。

{{production_url}}/index.phpを/休息/ V1 /カテゴリ/ 3

それが返され、

{ 
    "id": 3, 
    "parent_id": 2, 
    "name": "T-shirts", 
    "is_active": true, 
    "position": 1, 
    "level": 2, 
    "children": "", 
    "created_at": "2017-06-02 11:21:16", 
    "updated_at": "2017-06-02 11:21:16", 
    "path": "1/2/3", 
    "available_sort_by": [], 
    "include_in_menu": true, 
    "custom_attributes": [ 
     { 
      "attribute_code": "description", 
      "value": "<p>retest</p>" 
     }, 
     { 
      "attribute_code": "image", 
      "value": "Screen_Shot_2017-06-16_at_4.06.35_PM.png" 
     }, 
     { 
      "attribute_code": "display_mode", 
      "value": "PRODUCTS" 
     }, 
     { 
      "attribute_code": "is_anchor", 
      "value": "1" 
     }, 
     { 
      "attribute_code": "path", 
      "value": "1/2/3" 
     }, 
     { 
      "attribute_code": "children_count", 
      "value": "0" 
     }, 
     { 
      "attribute_code": "custom_use_parent_settings", 
      "value": "0" 
     }, 
     { 
      "attribute_code": "custom_apply_to_products", 
      "value": "0" 
     }, 
     { 
      "attribute_code": "url_key", 
      "value": "redwine" 
     }, 
     { 
      "attribute_code": "url_path", 
      "value": "redwine" 
     } 
    ] 
} 

iを呼び出す必要n catgoriesがある場合と仮定nカスタム属性を取得するためのapiです.1つのAPIですべてのカテゴリのすべての属性を取得するためのAPIはありますか?

答えて

0

Magento Api CatalogTreeInterfaceはMagento \ Framework \ Api \ ExtensibleDataInterfaceを拡張しません。つまり、カスタム属性または拡張属性をツリーレスポンスに追加できません。私の唯一の回避策は、自分のモジュールを作成して、ツリーインターフェースを拡張してカスタム属性を追加する新しいapi呼び出しを作成することでした。

関連する問題