magento2: REST API: Can't get store labels for product attribute label or attribute options label

As i understand the documentation, calls to: /V1/products/attributes/{attributeCode} /V1/products/attributes/ should return frontend labels for the attribute and for options. Like this for options:

"options": [
    {
      "label": "string",
      "value": "string",
      "sortOrder": 0,
      "isDefault": true,
      "storeLabels": [
        {
          "storeId": 0,
          "label": "string"
        }
      ]
    }
  ]

and like this for attribute label

"frontendLabels": [
    {
      "storeId": 0,
      "label": "string"
    }
  ]

In my tries i only get the default store view labels and values for options and null for the attribute labels like this:

 "options" : [
    {
      "label" : "string",
      "value" : "string"
    }
  ],
.
.
.
"frontend_labels" : null

Magento version is 2.0.2

/Thomas

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 20 (4 by maintainers)

Most upvoted comments

if you use /rest/all/V1… you can get the labels used on the admin view To bad it is not documented how you use storeviews in the rest api.

/1/store/storeView says:

[
  {
    "id": 1,
    "code": "default",
    "name": "Default Store View",
    "website_id": 1,
    "store_group_id": 1
  },
  {
    "id": 0,
    "code": "admin",
    "name": "Admin",
    "website_id": 0,
    "store_group_id": 0
  }
]

But to get admin you need to use all 👎

Hi, this is only a dirty workaround but you can get some ideas, just in case you really need to implement something: $connection= $this->resourceConnetion->getConnection(); $select = $connection->select() ->from( ['t1' => $this->resourceConnetion->getTableName('eav_attribute_option_value')] )->join( ['t2' => $this->resourceConnetion->getTableName('eav_attribute_option')], 't1.option_id=t2.option_id' )->join( ['t3' => $this->resourceConnetion->getTableName('eav_attribute')], 't3.attribute_id=t2.attribute_id' )->where( 't3.attribute_code = ?', 'your_attribute_code' )->where( 'store_id = ?', 0//for the admin labels ); $result = $connection->fetchAll($select);

Hello all

Also looking forward to the solution. This is critical for our integration

A note: all frontend labels (labes for all store views) are not needed, only a single store_code-specific label value is needed from these calls. It looks somewhat confusing that /rest/{store_code}/V1/products/attributes lists only store_code-specific option labels but is supposed to return attribute labels for all store views. It would be appropriate to include single store_code-specific “frontend_label” in the response next to “default_frontend_label” or even instead of it

Any news on this? Not fixed in 2.10