Inventory API

Last modified by unwiredbrain on Mon, May 11, 2009 03:26
Source|Old Revisions  

This is an old revision of the document!


Allows export/import catalog inventory.

Module: Mage_CatalogInventory

Resource: cataloginventory_stock_item

Aliases:

  • product_stock

Methods

cataloginventory_stock_item.list

Retrieve stock data by product ids

Return: array

Arguments:

  • array products - list of products IDs or Skus

Aliases:

  • product_stock.list

cataloginventory_stock_item.update

Update product stock data

Return: boolean

Arguments:

  • mixed product - product ID or Sku
  • array data - data to change (qty, is_in_stock)

Aliases:

  • product_stock.update

Faults

Fault Code Fault Message
101 Product not exists.
102 Product inventory not updated. Details in error message.

Examples

Example 1. Working with stock update

  1. $proxy = new SoapClient('http://magentohost/api/soap/?wsdl');
  2. $sessionId = $proxy->login('apiUser', 'apiKey');
  3.  
  4. // Get stock info
  5. var_dump($proxy->call($sessionId, 'product_stock.list', 'Sku'));
  6.  
  7. // Update stock info
  8. $proxy->call($sessionId, 'product_stock.update', array('Sku', array('qty'=>50, 'is_in_stock'=>1)));
  9.  
  10. var_dump($proxy->call($sessionId, 'product_stock.list', 'Sku'));

Example 2: listing multiple SKUs' data

  1. $client = new SoapClient('http://magentohost/api/soap/?wsdl');
  2. $sid = $client->login('apiUser', 'apiKey');
  3.  
  4. print_r(
  5.     $client->call(
  6.         $sid,
  7.         'product_stock.list',
  8.         array(
  9.             array( // Notice the nested array
  10.                 'sku1',
  11.                 'sku2',
  12.                 'sku3',
  13.                 ...
  14.                 'skuN'
  15.             )
  16.         )
  17.     )
  18. );



 

Magento 2 GitHub Repository

Magento Job Board - Some sort of tag line goes here

Latest Posts| View all Jobs