Bagisto Forum

    Bagisto

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    How to insert configurable product programmatically?

    General Discussion
    4
    4
    770
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      ttm.sanjay last edited by

      I would like to insert product and its attribute and variation by code. I am actually creating an custom API through which I can migrate products from my other source to bagisto. So I need some code reference to insert product variations into DB.

      1 Reply Last reply Reply Quote 0
      • devansh-webkul
        devansh-webkul last edited by

        Hi @ttm-sanjay,

        For configurable products, you just need additional data,

        For e.g.,

        For creating product,

        $request = [
            "type" => "simple",
            "attribute_family_id" => "1",
            "sku" => "90"
        ];
        

        On second phase you just edit the product,

        $request = [
          "channel" => "default",
          "locale" => "en",
          "sku" => "90",
          "name" => "Product 1",
          "url_key" => "product-1",
          "tax_category_id" => "",
          "new" => "1",
          "featured" => "1",
          "visible_individually" => "1",
          "status" => "1",
          "color" => "1",
          "size" => "6",
          "brand" => "10",
          "short_description" => "<p>Lorem Ipsum</p>",
          "description" => "<p>Lorem Ipsum</p>",
          "meta_title" => "Lorem Ipsum",
          "meta_keywords" => "Lorem Ipsum",
          "meta_description" => "Lorem Ipsum",
          "price" => "100.0000",
          "cost" => "",
          "special_price" => "",
          "special_price_from" => "",
          "special_price_to" => "",
          "width" => "",
          "height" => "",
          "depth" => "",
          "weight" => "90",
          "inventories" => [
            1 => "100"
          ],
          "images" => [
            389 => ""
          ],
          "categories" => [
            0 => "1"
          ],
          "channels" => [
            0 => "1"
          ]
        ];
        

        For programmatically I suggest you check this file method,
        packages/Webkul/Product/src/Http/Controllers/ProductController.php update() method.

        1 Reply Last reply Reply Quote 0
        • H
          Hossam Hamed last edited by

          and how to add configurable product to cart via api endpoint

          1 Reply Last reply Reply Quote 0
          • sanjay-webkul
            sanjay-webkul last edited by

            Hi there,
            Please take a reference from Here

            1 Reply Last reply Reply Quote 0
            • First post
              Last post