Magento Forum

   
Can not update Stock Availability / Is In Stock value via Magento API
 
Seany84
Jr. Member
 
Total Posts:  1
Joined:  2013-05-07
 

Background

I have a live and test Magento store. I generated a MagentoApi C# class from the WSDL of the Magento store.

Problem

I am able to update product quantities with no issues via my API class. I am now trying to set the Stock Availability field from the API but it will not change it’s value.

Code

[Test]
public void UpdateIsInStockField()
{
    MagentoStoreConfig storeConfig 
GetTestMagentoStore();
    var 
magentoApiRepo = new MagentoApiRepository(storeConfig);
    
catalogInventoryStockItemEntity magentoProduct magentoApiRepo.GetProductFromSku(new[] { "SKU-123456" });

    var 
productUpdated = new catalogInventoryStockItemUpdateEntity
                      {
                          is_in_stock 
0,
                          
manage_stock 0,
                          
use_config_manage_stock 0,
                          
qty = new Random().Next(50100).ToString(CultureInfo.InvariantCulture)
                      
};

    
magentoApiRepo.UpdateStockQuantity(magentoProduct.product_idproductUpdated);
}

Result

From the Magento store’s admin section, the quantity value changes for the product but the Stock Availability value has not changed.

I am setting the manage_stock and use_config_manage_stock as per the instructions outlined here in the Magento API reference guide.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top