This is a beta release of documentation for Magento 2.4, published for previewing soon-to-be-released functionality. Content in this version is subject to change. Links to the v2.4 code base may not properly resolve until the code is officially released.

Step 2. Create the configurable product

Create a configurable product tutorial

We have the information we need to create the Champ Tee configurable product.

The sample payload does not contain the price or the size. These attributes will be defined in the simple products.

The visibility attribute is set to 4, meaning the product can be found by browsing or searching. This value will be changed for the simple products.

Before you using this code sample, verify that the attribute values are the same in your installation. See Get the list of attributes defined in an attribute searchCriteria for more information.

Endpoint:

POST <host>/rest/default/V1/products

Payload:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
{
  "product": {
    "sku": "MS-Champ",
    "name": "Champ Tee",
    "attribute_set_id": 9,
    "status": 1,
    "visibility": 4,
    "type_id": "configurable",
    "weight": "0.5",
    "extension_attributes": {
        "category_links": [
            {
                "position": 0,
                "category_id": "11"
            },
            {
                "position": 1,
                "category_id": "12"
            },
            {
                "position": 2,
                "category_id": "16"
            }
        ]
    },
    "custom_attributes": [
        {
            "attribute_code": "description",
            "value": "The Champ Tee keeps you cool and dry while you do your thing. Let everyone know who you are by adding your name on the back for only $10."
        },
        {
            "attribute_code": "tax_class_id",
            "value": "2"
        },
        {
            "attribute_code": "material",
            "value": "148"
        },
        {
            "attribute_code": "pattern",
            "value": "196"
        },
        {
            "attribute_code": "color",
            "value": "52"
        }
    ]
  }
}

Response:

Show code sample
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
{
    "id": 2078,
    "sku": "MS-Champ",
    "name": "Champ Tee",
    "attribute_set_id": 9,
    "price": 0,
    "status": 1,
    "visibility": 4,
    "type_id": "configurable",
    "created_at": "2017-11-29 19:57:20",
    "updated_at": "2017-11-29 19:57:20",
    "weight": 0.5,
    "extension_attributes": {
        "website_ids": [
            1
        ],
        "category_links": [
            {
                "position": 0,
                "category_id": "11"
            },
            {
                "position": 1,
                "category_id": "12"
            },
            {
                "position": 2,
                "category_id": "16"
            }
        ],
        "stock_item": {
            "item_id": 2078,
            "product_id": 2078,
            "stock_id": 1,
            "qty": 0,
            "is_in_stock": false,
            "is_qty_decimal": false,
            "show_default_notification_message": false,
            "use_config_min_qty": true,
            "min_qty": 0,
            "use_config_min_sale_qty": 1,
            "min_sale_qty": 1,
            "use_config_max_sale_qty": true,
            "max_sale_qty": 10000,
            "use_config_backorders": true,
            "backorders": 0,
            "use_config_notify_stock_qty": true,
            "notify_stock_qty": 1,
            "use_config_qty_increments": true,
            "qty_increments": 0,
            "use_config_enable_qty_inc": true,
            "enable_qty_increments": false,
            "use_config_manage_stock": true,
            "manage_stock": true,
            "low_stock_date": null,
            "is_decimal_divided": false,
            "stock_status_changed_auto": 0
        },
        "configurable_product_options": [],
        "configurable_product_links": []
    },
    "product_links": [],
    "options": [],
    "media_gallery_entries": [],
    "tier_prices": [],
    "custom_attributes": [
        {
            "attribute_code": "description",
            "value": "The Champ Tee keeps you cool and dry while you do your thing. Let everyone know who you are by adding your name on the back for only $10."
        },
        {
            "attribute_code": "color",
            "value": "52"
        },
        {
            "attribute_code": "category_ids",
            "value": [
                "11",
                "12",
                "16"
            ]
        },
        {
            "attribute_code": "options_container",
            "value": "container2"
        },
        {
            "attribute_code": "required_options",
            "value": "0"
        },
        {
            "attribute_code": "has_options",
            "value": "0"
        },
        {
            "attribute_code": "url_key",
            "value": "champ-tee"
        },
        {
            "attribute_code": "tax_class_id",
            "value": "2"
        },
        {
            "attribute_code": "material",
            "value": "148"
        },
        {
            "attribute_code": "size",
            "value": "91"
        },
        {
            "attribute_code": "pattern",
            "value": "196"
        }
    ]
}

Verify this step

  • Log in to the Luma website and select Catalog > Products. The product appears in the grid.

Product page with configurable product

  • On the Luma storefront page, search for Champ. No results are returned.