2

code:

        $inventory = "http://example.com/index.php/rest/V1/stockStatuses/".$products_object->sku;
        $ch1 = curl_init($inventory);
        curl_setopt($ch1, CURLOPT_CUSTOMREQUEST, "GET");
        curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch1, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Authorization: Bearer " . json_decode($token))); 
        $stock_item = json_decode(curl_exec($ch1));

debug:

    object(stdClass)#28 (5) { 
    ["product_id"]=> int(259) 
    ["stock_id"]=> int(1) 
    ["qty"]=> int(103) 
    ["stock_status"]=> int(0) 
    ["stock_item"]=> object(stdClass)#29 (26) { 
        ["item_id"]=> int(259) 
        ["product_id"]=> int(259) 
        ["stock_id"]=> int(1) ["qty"]=> int(103) 
        ["is_in_stock"]=> bool(false) 
        ["is_qty_decimal"]=> bool(false) 
        ["show_default_notification_message"]=> bool(false) 
        ["use_config_min_qty"]=> bool(true) 
        ["min_qty"]=> int(0) 
        ["use_config_min_sale_qty"]=> int(1) 
        ["min_sale_qty"]=> int(1) 
        ["use_config_max_sale_qty"]=> bool(true) 
        ["max_sale_qty"]=> int(10000) 
        ["use_config_backorders"]=> bool(true) 
        ["backorders"]=> int(0)  
        ["use_config_notify_stock_qty"]=> bool(true) 
        ["notify_stock_qty"]=> int(1) 
        ["use_config_qty_increments"]=> bool(true) 
        ["qty_increments"]=> int(0) 
        ["use_config_enable_qty_inc"]=> bool(true) 
        ["enable_qty_increments"]=> bool(false) 
        ["use_config_manage_stock"]=> bool(true) 
        ["manage_stock"]=> bool(true) 
        ["low_stock_date"]=> NULL 
        ["is_decimal_divided"]=> bool(false) 
        ["stock_status_changed_auto"]=> int(0) 
    } 

}

if i want to update a product from "no stock" to a positive interger, which one of them i need to update actually?

1 Answer 1

-1
  1. is_in_stock : is a product stock status.

    Database table : cataloginventory_stock_item.

    Values : (0, 1)

  2. stock_status : is product stock inventory.

    Database table : cataloginventory_stock_status item.

    Values : (0, 1)

When you set the Stock Status product attribut in admin, Magento save that value in the both is_in_stock and stock_status, also for the product quantity, it set in the both tables, when the quantity is set to 0, Magento Update the is_in_stock, stock_status to 0.

stock_status display or not the product on front but there is also a need to have is_in_stock otherwise you can't buy the product (Add product to cart).

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.