Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

API Change: Sending Updates in an Array
 
gbear
Jr. Member
 
Total Posts:  19
Joined:  2008-08-08
 

Currently the product_stock.update and product.update allow you to send one sku update at a time.  Would be helpful if it could accept an Array of SKU’s and their related updates.  So rather than looping through and executing updates via web service, would pass in a single update with an array of SKU’s. 

Inside Magento it could process these updates one at a time, or better would be to check if an array is passed in and then update them in a single SQL call Currently takes about 5 hours to process 500 updates, this would reduce that time to about 5 minutes.

So instead of this, in a loop

try {
            $client
->call($sessionId'product_stock.update', array($product->sku, array('qty' => $product->qty ) ) );
        
catch (SoapFault $e{
                    
echo $e;
        
}

Would do something like this

//build the array of updates needed
$updates = array();
while ( 
$product db_fetch_object$res ) )  {
    $updates[$product
->sku] = array( 'qty' => $product->qty );  //something like this...
}
//and pass them all in for processing
try {
   $client
->call($sessionId'product_stock.update'$updates ) );
        
catch (SoapFault $e{
                    
echo $e;
        
}
 
Magento Community Magento Community
Magento Community
Magento Community
 
JKwan13
Member
 
Total Posts:  63
Joined:  2008-06-12
 

You could use the multiCall function.  http://www.magentocommerce.com/wiki/doc/webservices-api/introduction#basic_api_methods

$result $client->multiCall($session, array(
     array(
'somestuff.method'),
     array(
'somestuff.method''arg1'),
     array(
'somestuff.method', array('arg1''arg2'))
));

I used it and although it is a little quicker, there is no way for me to track how far it has gone through the list.
Also, since I keep getting “Error getting http headers” randomly, once this function hits this error, it exits and I have no way to know where it stopped and therefore I can’t just loop through it.

Maybe you know a way to do these things?

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