cancel
Showing results for 
Search instead for 
Did you mean: 

API: add new text swatch

API: add new text swatch

Hello,

 

I want to create for products new attributes per API.

 

/rest/default/V1/products/attributes
Is this for creating new attributes?
 
Example:
I have Attribute set "Video" (ID:10)
in this I want to add in the group "Attributes" new attributes:
pixel_format
screen_size
 
I can create "pixel_format" with:
[POST] /rest/default/V1/products/attributes
 
But how I can add the Text swatches? And how can I link this attribute to the correct attribute group?
 
Thank you!
1 REPLY 1

Re: API: add new text swatch

Hello,

 

I found now:

/rest/default/V1/products/attributes/{attributeCode}/options

 

with the payload:

{
    "option": {
        "label": "red",
        "value": "red_default",
        "is_default": "false",
        "sort_order": 0,
        "store_labels": [
            {
                "store_id": 1,
                "label": "red en"
            },
            {
                "store_id": 2,
                "label": "red de"
            }
        ]
    }
}

response:

"id_5476"

in admin:

 

Anmerkung 2020-04-30 082234.jpg

 

so far, ok.

 

But when I read the options:

[
    {
        "label": " ",
        "value": ""
    },
    {
        "label": "21/1.7” 12 Megapixel Progressiv CMOS",
        "value": "5431"
    },
    {
        "label": "red en",
        "value": "5476"
    }
]

he return the first store label and the id(!)

 

the id(swatch) was "red_default"

 

Wow can I get from id 5476 the text "red_default"?