Send info from Netsuite to Magento Api

2019-09-14 04:58发布

问题:

I am trying to send info from Netsuite to Magento, via Magento API. In a normal condition, I execute

    $user       =   'user';
    $pass       =   'password';

    $url        =   'http://example.hosting.com/magento/api/soap/?wsdl';
    $webClient  =   new SoapClient($url);
    $webSession =   $webClient->login($user, $pass);

    $result     =   $webClient->call($webSession, 'ApiMethod', 'data');

Buy I don´t undestand how make it in a Script of Netsuite. I found a method nlapiRequestURL, but I don´t understand how make the login and send the session.

Thanks.

回答1:

If you are planning on hosting code within NetSuite to talk to Magento, you'd probably be better served using Magento's REST API since it will be much easier to use. Otherwise you'd need a Javascript SOAP client, which isn't part of NetSuite and unlikely to work correctly in that environment.

With the REST API, you basically hit different endpoints for each type of record e.g.

  • http://magentohost/api/rest/orders for Sales Orders
  • http://magentohost/api/rest/stockitems for inventory items

Then you parse your response for the data you need, or post the data you want to create.