Step 2. Create the simple products
Before you run the code, please verify that the attribute values are the same in your installation. See Get the list of attributes defined in an attribute set for more information.
We will create four simple products: RAM 12GB
, RAM 24GB
, Monitor 15"
and Monitor 17"
.
Endpoint:
1
POST http://domain.com/rest/default/V1/products
Payload 1:
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
{
"product": {
"sku": "RAM-12GB",
"name": "RAM 12GB",
"attribute_set_id": 4,
"price": 25,
"status": 1,
"visibility": 4,
"type_id": "simple",
"weight": "0.5",
"extension_attributes": {
"category_links": [
{
"position": 0,
"category_id": "32"
}
],
"stock_item": {
"qty": "10",
"is_in_stock": true
}
},
"custom_attributes": [
{
"attribute_code": "description",
"value": "RAM 12GB Unit"
},
{
"attribute_code": "tax_class_id",
"value": "2"
}
]
}
}
Response 1:
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
{
"id": 16,
"sku": "RAM-12GB",
"name": "RAM 12GB",
"attribute_set_id": 4,
"price": 25,
"status": 1,
"visibility": 4,
"type_id": "simple",
"created_at": "2022-04-08 21:57:34",
"updated_at": "2022-04-08 21:57:34",
"weight": 0.5,
"extension_attributes": {
"website_ids": [
1
],
"category_links": [
{
"position": 0,
"category_id": "32"
}
],
"stock_item": {
"item_id": 16,
"product_id": 16,
"stock_id": 1,
"qty": 10,
"is_in_stock": true,
"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
}
},
"options": [],
"media_gallery_entries": [],
"custom_attributes": [
{
"attribute_code": "options_container",
"value": "container2"
},
{
"attribute_code": "msrp_display_actual_price_type",
"value": "0"
},
{
"attribute_code": "url_key",
"value": "ram-12g"
},
{
"attribute_code": "required_options",
"value": "0"
},
{
"attribute_code": "has_options",
"value": "0"
},
{
"attribute_code": "tax_class_id",
"value": "2"
},
{
"attribute_code": "category_ids",
"value": [
"32"
]
},
{
"attribute_code": "description",
"value": "RAM 12GB Unit"
}
]
}
Payload 2:
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
{
"product": {
"sku": "RAM-24GB",
"name": "RAM 24GB",
"attribute_set_id": 4,
"price": 50,
"status": 1,
"visibility": 4,
"type_id": "simple",
"weight": "0.5",
"extension_attributes": {
"category_links": [
{
"position": 0,
"category_id": "32"
}
],
"stock_item": {
"qty": "10",
"is_in_stock": true
}
},
"custom_attributes": [
{
"attribute_code": "description",
"value": "RAM 24GB Unit"
},
{
"attribute_code": "tax_class_id",
"value": "2"
}
]
}
}
Response 2:
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
{
"id": 17,
"sku": "RAM-24GB",
"name": "RAM 24GB",
"attribute_set_id": 4,
"price": 50,
"status": 1,
"visibility": 4,
"type_id": "simple",
"created_at": "2022-04-08 22:02:40",
"updated_at": "2022-04-08 22:02:40",
"weight": 0.5,
"extension_attributes": {
"website_ids": [
1
],
"category_links": [
{
"position": 0,
"category_id": "32"
}
],
"stock_item": {
"item_id": 17,
"product_id": 17,
"stock_id": 1,
"qty": 10,
"is_in_stock": true,
"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
}
},
"options": [],
"media_gallery_entries": [],
"custom_attributes": [
{
"attribute_code": "options_container",
"value": "container2"
},
{
"attribute_code": "msrp_display_actual_price_type",
"value": "0"
},
{
"attribute_code": "url_key",
"value": "ram-24g"
},
{
"attribute_code": "required_options",
"value": "0"
},
{
"attribute_code": "has_options",
"value": "0"
},
{
"attribute_code": "tax_class_id",
"value": "2"
},
{
"attribute_code": "category_ids",
"value": [
"32"
]
},
{
"attribute_code": "description",
"value": "RAM 24GB Unit"
}
]
}
Payload 3:
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
{
"product": {
"sku": "Monitor-15",
"name": "Monitor 15\"",
"attribute_set_id": 4,
"price": 100,
"status": 1,
"visibility": 4,
"type_id": "simple",
"weight": "0.5",
"extension_attributes": {
"category_links": [
{
"position": 0,
"category_id": "32"
}
],
"stock_item": {
"qty": "10",
"is_in_stock": true
}
},
"custom_attributes": [
{
"attribute_code": "description",
"value": "Monitor 15\""
},
{
"attribute_code": "tax_class_id",
"value": "2"
}
]
}
}
Response 3:
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
{
"id": 18,
"sku": "Monitor-15",
"name": "Monitor 15\"",
"attribute_set_id": 4,
"price": 100,
"status": 1,
"visibility": 4,
"type_id": "simple",
"created_at": "2022-04-08 22:04:11",
"updated_at": "2022-04-08 22:04:11",
"weight": 0.5,
"extension_attributes": {
"website_ids": [
1
],
"category_links": [
{
"position": 0,
"category_id": "32"
}
],
"stock_item": {
"item_id": 18,
"product_id": 18,
"stock_id": 1,
"qty": 10,
"is_in_stock": true,
"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
}
},
"options": [],
"media_gallery_entries": [],
"custom_attributes": [
{
"attribute_code": "options_container",
"value": "container2"
},
{
"attribute_code": "msrp_display_actual_price_type",
"value": "0"
},
{
"attribute_code": "url_key",
"value": "monitor-15"
},
{
"attribute_code": "required_options",
"value": "0"
},
{
"attribute_code": "has_options",
"value": "0"
},
{
"attribute_code": "tax_class_id",
"value": "2"
},
{
"attribute_code": "category_ids",
"value": [
"32"
]
},
{
"attribute_code": "description",
"value": "Monitor 15\""
}
]
}
Payload 4:
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
{
"product": {
"sku": "Monitor-17",
"name": "Monitor 17\"",
"attribute_set_id": 4,
"price": 150,
"status": 1,
"visibility": 4,
"type_id": "simple",
"weight": "0.5",
"extension_attributes": {
"category_links": [
{
"position": 0,
"category_id": "32"
}
],
"stock_item": {
"qty": "10",
"is_in_stock": true
}
},
"custom_attributes": [
{
"attribute_code": "description",
"value": "Monitor 17\""
},
{
"attribute_code": "tax_class_id",
"value": "2"
}
]
}
}
Response 4:
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
{
"id": 19,
"sku": "Monitor-17",
"name": "Monitor 17\"",
"attribute_set_id": 4,
"price": 150,
"status": 1,
"visibility": 4,
"type_id": "simple",
"created_at": "2022-04-08 22:06:21",
"updated_at": "2022-04-08 22:06:21",
"weight": 0.5,
"extension_attributes": {
"website_ids": [
1
],
"category_links": [
{
"position": 0,
"category_id": "32"
}
],
"stock_item": {
"item_id": 19,
"product_id": 19,
"stock_id": 1,
"qty": 10,
"is_in_stock": true,
"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
}
},
"options": [],
"media_gallery_entries": [],
"custom_attributes": [
{
"attribute_code": "options_container",
"value": "container2"
},
{
"attribute_code": "msrp_display_actual_price_type",
"value": "0"
},
{
"attribute_code": "url_key",
"value": "monitor-17"
},
{
"attribute_code": "required_options",
"value": "0"
},
{
"attribute_code": "has_options",
"value": "0"
},
{
"attribute_code": "tax_class_id",
"value": "2"
},
{
"attribute_code": "category_ids",
"value": [
"32"
]
},
{
"attribute_code": "description",
"value": "Monitor 17\""
}
]
}
Verify this step
- Log in to the Adobe Commerce Admin Panel and select Catalog > Products and confirm that your products appear in the grid.
If you do not see your products in the catalog, you can try reindexing and clearing the cache.