Schogini is Magento2 ready. Are you?

Get started with Magento 2 | Need expert Magento2 support?

Magento API via SOAP


Category: Magento 1.9

Magento allows other applications connect to it through a Remote API - based upon SOAP or XML-RPC. This allows Magento to be integrated with other third applications like OpenERP.

Basic Steps:

  1. Create a web service role
  2. Create a web service user
  3. Assign the role to the user
  4. Connect to the web service (via SOAP) and get a Session ID
  5. Make the API calls

Create a web service role

Login into your Magento Admin > System > Web Services > SOAP/XML-RPC Roles > Add New Role

Create a web service user

Login into your Magento Admin > System > Web Services > SOAP/XML-RPC Users > Add New User

Assign the role to the user

Login into your Magento Admin > System > Web Services > SOAP/XML-RPC Users > Click the user you created > User Role > Select the role you created.

Connect to the web service and get a Session ID & Make the API calls

Magento's API has 2 versions - v1 & v2. Here you will find code for both the versions.

// Magento API v1
$api_url_v1 = "http://127.0.0.1/magento-19/api/soap/?wsdl=1";
$username   = 'soap_gsa'; // Username
$apikey     = 'soap_gsa_api'; // API Key

// retreive session id from login
$cli = new SoapClient($api_url_v1);
$session_id = $cli->login($username, $apikey);

// call customer.list method
$result = $cli->call($session_id, 'product.list', array(array()));
var_dump($result);
// Magento API v2 SOAP
$api_url_v2 = "http://127.0.0.1/magento-19/api/v2_soap/?wsdl=1";
$username   = 'soap_gsa'; // Username
$apikey     = 'soap_gsa_api'; // API Key

// retreive session id from login
$cli = new SoapClient($api_url_v2);
$session_id = $cli->login($username, $apikey);

// call catalogProductList method
$result = $cli->catalogProductList($session_id);
var_dump($result);


 

Schogini's customer service extends beyond the natural boundaries. ~ Timothy Johnson

Schogini assures 24x7 - 6 hour turn around ticket response time and 24 hour Email response time (support@schogini.com)