0

I created a configurable product using the below link and Payload

1 Configurable Product Created

http://localhost/rest/V1/products

{
  "product": {
    "sku": "Js-Con",
    "name": "Js-Con",
    "attribute_set_id": 4,
    "status": 1,
    "visibility": 4,
    "type_id": "configurable",
    "weight": "0.5",
    "extension_attributes": {
        "category_links": [
            {
                "position": 0,
                "category_id": "5"
            }
        ]
    },
    "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"
        }
    ]
  }
}

2 Simple Product Created

    http://localhost/rest/V1/products

{
  "product": {
    "sku": "Js-Black-Xl",
    "name": "Js-Bblack-Xl",
    "attribute_set_id": 4,
    "price": 25,
    "status": 1,
    "visibility": 1,
    "type_id": "simple",
    "weight": "0.5",
    "extension_attributes": {
        "category_links": [
            {
                "position": 0,
                "category_id": "5"
            }
        ],
        "stock_item": {
            "qty": "10",
            "is_in_stock": true
        }
    },
    "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": "jasani_size",
            "value": "29"
        },
            {
            "attribute_code": "jasani_color",
            "value": "30"
        }
    ]
  }
}

3 When I Assign options to configurable product I get this error

http://Localhost/rest/V1/configurable-products/Js-Con/options

{
  "option": {
    "attribute_id": "146",
    "label": "de",
    "position": 0,
    "is_use_default": true,
    "values": [
      {
        "value_index":31

      }
    ]
  }


}

{
    "message": "An error occurred while saving the option. Please try to save again.",
    "trace": "#0 [internal function]: Magento\\ConfigurableProduct\\Model\\OptionRepository->save('Js-Con', Object(Magento\\ConfigurableProduct\\Model\\Product\\Type\\Configurable\\Attribute))\n#1 /var/www/html/vendor/magento/module-webapi/Controller/Rest/SynchronousRequestProcessor.php(95): call_user_func_array(Array, Array)\n#2 /var/www/html/vendor/magento/module-webapi/Controller/Rest.php(188): Magento\\Webapi\\Controller\\Rest\\SynchronousRequestProcessor->process(Object(Magento\\Framework\\Webapi\\Rest\\Request\\Proxy))\n#3 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\\Webapi\\Controller\\Rest->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#4 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\\Webapi\\Controller\\Rest\\Interceptor->___callParent('dispatch', Array)\n#5 /var/www/html/jasani/vendor/magento/framework/Interception/Interceptor.php(153): Magento\\Webapi\\Controller\\Rest\\Interceptor->Magento\\Framework\\Interception\\{closure}(Object(Magento\\Framework\\App\\Request\\Http))\n#6 /var/www/html/jasani/generated/code/Magento/Webapi/Controller/Rest/Interceptor.php(26): Magento\\Webapi\\Controller\\Rest\\Interceptor->___callPlugins('dispatch', Array, Array)\n#7 /var/www/html/vendor/magento/framework/App/Http.php(135): Magento\\Webapi\\Controller\\Rest\\Interceptor->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#8 /var/www/html/vendor/magento/framework/App/Bootstrap.php(258): Magento\\Framework\\App\\Http->launch()\n#9 /var/www/html/index.php(40): Magento\\Framework\\App\\Bootstrap->run(Object(Magento\\Framework\\App\\Http\\Interceptor))\n#10 {main}"
}

I need to add multiple attribute option in one API call. How to Assign Child Products to parent products.

https://devdocs.magento.com/guides/v2.3/rest/tutorials/configurable-product/create-configurable-product.html

I followed the above link but I'm so confused. Thanks in advance

0

If you create a product manually, then get it via the API you can see how it’s structured and created your JSON file that way, this is how I learnt the API!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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