2

I'm trying to POST a grouped product to my magento 2 site. Doing this for a simple product is easy enough. How to do it can be found here.

But what is doesn't specify is how to add a grouped product. I have tried something like this:

POST rest/V1/carts/mine/items


{
"cartItem": {
    "sku": "arduino-kit-10000",
    "qty": "1",
    "quote_id": "5",
    "product_links": [
        {
            "sku": "arduino-kit-10000",
            "linked_product_sku": "13620748",
            "extension_attributes": [
                {
                    "qty": "5"
                }
            ]
        },
        {
            "sku": "arduino-kit-10000",
            "linked_product_sku": "1111111130",
            "extension_attributes": [
                {
                    "qty": "5"
                }
            ]
        }
    ]
}
}

But this gives me the following error:

   "message": "Property \"ProductLinks\" does not have accessor method \"getProductLinks\" in class \"Magento\\Quote\\Api\\Data\\CartItemInterface\".",

Does anyone know how this can be done? Or if I can just add the simple products by themselves and let Magento know they belong to a grouped product?

1 Answer 1

0

use 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.