cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 1 Soap 403 Forbidden

SOLVED

Magento 1 Soap 403 Forbidden

Ciao a tutti, sto cercando di modificare dei prodotti tramite api. Facendo una chiamata soap su un singolo prodotto (sto provando a disabilitarlo), funziona tutto correttamente, ma se provo con un ciclo a ripetere l'azione per n prodotti successivi ottengo come errore 403 SoapFault Forbidden.
Ho provato a chiudere e riaprire la sessione ma l'errore persiste.
Nei log di Apache leggo 'client denied by server configuration: /var/www/magento/httpdocs/api'.
Qualcuno ha incontrato un problema simile?
Grazie!
2 REPLIES

Re: Magento 1 Soap 403 Forbidden

Hello @PaolaM

 

$client = new SoapClient('http://example.com/index.php/api/soap/?wsdl');    
$session = $client->login('xxxx', 'xxxxx');

 // $productInfo is array which contains all product sku and its quantities which will update to another server 

 $productInfo = array( 
                array('sku'=>'sku1','qty'=>'50000'),
                array('sku'=>'sku2','qty'=>'110'),
                );

$start = microtime(true);
foreach($productInfo as $product )
{
    $calls[] = array('product_stock.update', array($product['sku'], array('qty'=>$product['qty'])));
}

  /* 2 products will go in one request to another server for product   update   stock data(in my case quantities) using SOAP API multiCall method 
 IF YOU HAVE LOTS OF PRODUCT FOR UPDATE TO ANOTHER SERVER THEN YOU CAN REPLACE VALUE IN array_chunk function(in my case 2) 2 is total products data
   */

 foreach(array_chunk($calls, 2) as $skuChunk)
  {
     $result = $client->multiCall($session, $skuChunk);
  }
  echo $time_elapsed_secs = microtime(true) - $start; // How many times will be elapsed for this operation

Hope it will help you.

 

If works then mark as the solution or give kudos.

 

 

Re: Magento 1 Soap 403 Forbidden

It works, thank you!