0

How can I create a grouped product with the magento api in only one post. I know I can create configurable products in only one post adding the options in the next attributes

"configurable_product_options": [
                {
                    "attribute_id": "663",
                    "label": "co_color_filtro",
                    "values": [
                        {
                            "value_index": 9
                        }
                    ]
                }
            ],
            "configurable_product_links": []

How can I do this with a grouped product? Because the magento tutorial uses differents endpoint for create the product and add the simple items https://developer.adobe.com/commerce/webapi/rest/tutorials/grouped-product/

I tried doing something like this

  "products": [
    {
      "sku": "new-grouped",
      "name": "New Grouped Product",
      "attribute_set_id": 4,
      "type_id": "grouped",
      "visibility": 4,
      "status": 0,
      "extension_attributes": {
        "website_ids": [4],
        "category_links": [
          {
            "position": 0,
            "category_id": "2083"
          }
        ],
        "product_links": [
          {
            "link_type": "associated",
            "linked_product_sku": "009-9031191",
            "linked_product_type": "simple",
            "position": 1,
            "extension_attributes": {
              "qty": 1
            }
          },
          {
            "link_type": "associated",
            "linked_product_sku": "009-9031220",
            "linked_product_type": "simple",
            "position": 2,
            "extension_attributes": {
              "qty": 1
            }
          },
          {
            "link_type": "associated",
            "linked_product_sku": "009-9036452",
            "linked_product_type": "simple",
            "position": 3,
            "extension_attributes": {
              "qty": 1
            }
          }
        ]
      }
    }
  ]
}

1 Answer 1

0

Use with endpoint POST rest/V1/products:

{
  "product": {
    "sku": "Luma-Group",
    "name": "Luma Group Of Bags",
    "attribute_set_id": 15,
    "status": 1,
    "visibility": 4,
    "type_id": "grouped",
    "extension_attributes": {
        "category_links": [
            {
                "position": 0,
                "category_id": "4"
            }
        ],
        "stock_item": {
            "is_in_stock": true
        }
    },
    "product_links": [
        {
            "sku": "Luma-Group",
            "link_type": "associated",
            "linked_product_sku": "24-WB04",
            "linked_product_type": "simple",
            "position": 0,
            "extension_attributes": {
                "qty": 0
            }
        },
        {
            "sku": "Luma-Group",
            "link_type": "associated",
            "linked_product_sku": "24-WB03",
            "linked_product_type": "simple",
            "position": 1,
            "extension_attributes": {
                "qty": 0
            }
        },
        {
            "sku": "Luma-Group",
            "link_type": "associated",
            "linked_product_sku": "24-WB05",
            "linked_product_type": "simple",
            "position": 2,
            "extension_attributes": {
                "qty": 0
            }
        }
    ],
    "custom_attributes": [
        {
            "attribute_code": "description",
            "value": "This is Group description for product."
        }
    ]
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.