Magento – Magento 2 Get Attribute collection

attributescollection;magento2

I have Custom category attribute id for ex 200.

I want to get Attribute Option label from Value in magento 2 if any clue is also much appreciate.

Best Answer

You can use \Magento\Catalog\Api\CategoryAttributeOptionManagementInterface::getItems service call. For example if use this call over Rest WebApi: GET http://magento2.local/rest/V1/categories/attributes/display_mode/options you get

[
  {
    "label": "Products only",
    "value": "PRODUCTS"
  },
  {
    "label": "Static block only",
    "value": "PAGE"
  },
  {
    "label": "Static block and products",
    "value": "PRODUCTS_AND_PAGE"
  }
]