search
top

Stock configuration using Magento API

In one of my post I explained the basics of SOAP API, please refer Magento SOAP API before proceeding further

I am listing here the methods to update Product’s stock related information using SOAP API

<?php
$proxy = new SoapClient('http://url/api/soap/?wsdl');
$sessionId = $proxy->login('uname', 'upass@123'); 

$skus = array('abc123','abc234');

try
{
	
foreach($skus as $sku)
{
        $stockItemData = array(
            'stock_data' => array(
            'use_config_min_qty' => 0,
            'min_qty'=> 1,
            'is_in_stock' => 1
        ));

        $result = $proxy->call(
            $sessionId,
            'catalog_product.update',
            array(
                $sku,
                $stockItemData,
                1,
                'sku'
            )
        );

	echo $sku.'-';
        echo '<br/>';
}
}catch(Exception $e)
{
	echo $e->getMessage();
}
$proxy->endSession($sessionId);

?>

Hope this is helpful

Leave a Reply

top