3

I want to create configurable product programmatically. I have followed below steps. But got the error to last step.

  • Created the simple product programmatically and its working.
  • Try to create configurable product programmatically. By this, product added but configuration section blank, the simple product doesn't add.
  • Then try to link simple product to configurable product but this one also not working and got this error "Option values are not specified."

I am using Magento 2.1.4

Can any one help me to create configurable product programmatically?

Thank you

0

Got solution so writing answer of my own question. We can achieve this by API.


$data = [
    "product"=> [
        "sku"=> "config_api_test",
        "name"=> "cofig using rootways api",
        "type_id"=> "configurable",
        "attribute_set_id"=> 4,
        "price"=> "10.12",
        "status"=> 1,
        "visibility"=> 4,
        "extension_attributes"=> [
            "stock_item"=> [
                "is_in_stock"=> 1,
                "qty"=> "10"
            ],

            "configurable_product_options" =>[
             [
               "attribute__id"=>"93",
               "label"=>"Colour",
               "position"=>0,
               "values"=>[
                 [
                   "value_index"=>1
                 ],
                 [
                   "value_index"=>2
                 ]
               ]
             ],
             [
               "attribute__id"=>"141",
               "label"=>"Size",
               "position"=>1,
               "values"=>[
                 [
                   "value_index"=>1
                 ],
                 [
                   "value_index"=>2
                 ]
               ]
             ]
           ],


            "configurable_product_links" => [
                2309,
                2310
            ]

        ]
    ]
];
| improve this answer | |

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.