I am using following code to get the stock detail I am getting product stock of productId 149428

$proxy = new SoapClient('http://yourstore.com/api/?wsdl');
$sessionId = $proxy->login('apiuser', 'apiKey');
$result = $proxy->call($sessionId, 'product_stock.list','149428');


array(1) { [0]=> array(4) { ["product_id"]=> string(6) "149428" ["sku"]=> string(13) "n12345" ["qty"]=> string(6) "1.0000" ["is_in_stock"]=> string(1) "1" } }

But I want to retrieve all products stock list instead of getting single product stock details.

I tried using the below method but I am not getting a result,

$result = $proxy->call($sessionId, 'product_stock.list');


$result = $client->call($session, 'cataloginventory_stock_item.list');

Thank you in advance.

  • What happens, if you try the other two? Oct 3, 2016 at 6:33
  • it displays result as array(0) { }
    – Siraj M
    Oct 3, 2016 at 6:50
  • @fabian is there any solutions for that please do help me
    – Siraj M
    Oct 3, 2016 at 8:17
  • Reading the docs brings me to the assumption, that you have to implement your own API if you want "all", but you can pass an array with "all" ids, then you get all. You can read the code of the api response (don't ask me, what class handles that - no idea) and check, whether me/doc is wrong. Oct 3, 2016 at 20:25
  • @Fabian I tried sending ids in array but it did not work. as its reading first id from array and skipping the rest all
    – Siraj M
    Oct 4, 2016 at 3:45

3 Answers 3


You can use magento api version 2 for getting different product stocks in a single call. Try below code:

$proxy = new SoapClient('http://magento-local.com/api/v2_soap?wsdl'); //Means you are calling magento api V2
$sessionId = $proxy->login('test', 'test123'); // TODO : change login and pwd if necessary

//If you are passing product id
$stocks = $proxy->catalogInventoryStockItemList($sessionId, array (905, 880)); //905 and 880 are my simple product ids

//If you are passing product sku
$stocks = $proxy->catalogInventoryStockItemList($sessionId, array ('sku1', 'sku2'));



For more details refer: http://devdocs.magento.com/guides/m1x/api/soap/catalogInventory/cataloginventory_stock_item.list.html

 $products = $proxy->call($sessionId, 'product_stock.list', array(array("sku1","sku2","sku3"));

Yes, the nested arrays are necessary. In mine I also had to append a blank space at the end of each sku, so it is actually:

 $products = $proxy->call($sessionId, 'product_stock.list', array(array("sku1 ","sku2 ","sku3 "));

in my case. Not sure why, just thrilled when I got it to work.

I have about a thousand products, but it seems to overload the server to put them all in one call, so I'm "chunking" the sku array like so:

foreach (array_chunk($sku_array, 100) as $skuChunk) {

    try {
        $products = $proxy->call($sessionId, 'product_stock.list', array($skuChunk));
    catch (SoapFault $e) {
            echo $e->getMessage();

You can use Below code for get all product stock list.

ini_set('display_errors', 1);
$productsCollection = Mage::getModel('catalog/product')->getCollection();
$skus = array();
foreach ($productsCollection as $product) {
    $skus[] = $product->getSku();

$client = new SoapClient('http://yourhost.com/api/v2_soap/?wsdl=1');
$session = $client->login('apiUser', 'apiKey');
$result = $client->catalogInventoryStockItemList($session, $skus);
    echo "<pre>";
    echo "</pre>"; 

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.