Reputation: 11
I am using Soap Api and want to get product list whose stock is not 0, meaning there is at least 1 inventory(Stock) of the product in magento. I am using this type of code but it is not working.
$proxy = new SoapClient('http://magentohost/api/v2_soap/?wsdl');
$sessionId = $proxy->login((object)array('username' => 'apiUser', 'apiKey' => 'apiKey'));
$result = $proxy->catalogInventoryStockItemList((object)array('sessionId' => $sessionId->result, 'productIds' => array(1,2)));
var_dump($result->result);
Upvotes: 0
Views: 1510
Reputation: 369
use v1 api
$proxy = new SoapClient('http://magentohost/api/soap/?wsdl');
$session = $client->login('apiUser', 'apiKey');
$proxy->call($session, 'catalog_product.info',array(1,2));//productIds
Upvotes: 0
Reputation: 68
Use the code below, it worked for me:
$proxy = new SoapClient('http://yourstore.com/api/v2_soap/?wsdl');
$sessionId = $proxy->login('apiUserName', 'apiKey');
$result = $proxy->catalogProductList($sessionId);
var_dump($result);
If this did not work for you try to replace the url with the following (add "index.php") http://yourstore.com/index.php/api/v2_soap/?wsdl
Try adding the following lines before the code to enable error logging to see what the error is, seeing a blank screen might be because there is an error but you dont see it:
ini_set('display_errors', true);
error_reporting(E_ALL);
Can you also access this URL "yourstore.com/api/v2_soap/?wsdl" or this "yourstore.com/index.php/api/v2_soap/?wsdl" directly in your browser and let me know what you see? you should be able to see an XML document, if there is a setting issue, you will see something like "Invalid service adapter" or somekind of an error message.
Upvotes: 1