1

Using Magento 2, I'm trying to change Manage Stock attribute via rest API however does not seem to work via both the stockItems endpoint or the product one. Updating quantity seems to work fine.

Tried like below initially:

    $url = "https://www.magestore.com/rest/all/V1/products/" . $sku;
    $post_data = array(
        'product' =>
        array(
            'sku' => $sku,
            'extension_attributes' => 
                array(
                    "stock_item" => array( 
                        "qty" => $qty,
                        "is_in_stock" => $is_in_stock,
                        "manage_stock" => true
                    )
                )
            )
        );

Then tried like this for the stockItems endpoint:

    $url = "https://www.magestores.com/rest/V1/products/" . $sku . "/stockItems/1";
    $post_data = array(
        "stock_item" => array( 
                "qty" => $qty,
                "is_in_stock" => $is_in_stock,
                "manage_stock" => true
            )
        );

However neither seem to change manage stock to true for me, is this possible to achieve with Rest API?

0

Ok sorry figured it out already, I think both were trying however use_config_manage_stock was still set to true. Changing post data to include this being set to false did the trick:

    $post_data = array(
        "stock_item" => array( 
                "qty" => $qty,
                "is_in_stock" => $is_in_stock,
                "use_config_manage_stock" => false,
                "manage_stock" => true
            )
        );

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.