NetSuite Magento Integration Made Easy

There are products like Celigo and Boomi that integrate NetSuite and Magento. Having worked with one of them, I found it equally as complicated as using the native Magento API. Magento has a very robust API, so here is how I handled data synchronization between the two systems. I did it directly from within NetSuite.

First, I setup an integration in Magento. System >> Integrations

I created a new integration. Once you create your integration, you’ll need the Access Token to connect to the API.

I reviewed the API’s “Admin Endpoints” at https://developer.adobe.com/commerce/webapi/rest/quick-reference/
Get requests fetch data. Post and Put will add and update. I found that Post actually does both. It can add or update. I didn’t see that in the documentation, but found it to be true in practice.

Next, I coded up a number of example API calls using Postman (Freely downloadable tool). If you place the token you created ealier in the workspace, it can be inherited by all API calls under it.

Using the Admin endpoints, you can code up examples of “interactions” with Magento through the API. Here is an example of fetching a single product. Plug in your URL and your token in the workspace “Authorization” tab.

Translating this to code which runs directly in Netsuite looks like this. Obviously, the token you used above along with your URL replace the x’s. The response comes back as a Jasonized object in the response.body.

I found that using a Map Reduce script to collect whatever data you wish to move between the two systems in the getInputData method and then distributing all updates to the map method works best. In the example above I am updating a single product using a POST request. Magento also supports bulk inputs which allow you to submit multiple requests in a single API call. I’ve found this to be only slightly faster than doing it one at a time, and much harder to manage errors. If the requests are submitted in bulk, asynchronously, you much check progress, and once done associate each request with the response based on an identifier. If a single request fails, you’d get the error with an identifier which ties back to the actual (single) request that failed. Troublesome and only slightly faster. Once I got bulk requests working, I quit using them. The increased performance wasn’t enough to offset the extra work. Also, in my reading, I learned that Magento supports bulk inputs by simply creating an internal queue and processing each request one at a time. Pointless!

I found that in a Map Reduce script, I could fetch all products (or contacts, or categories, or whatever) by using the search feature of the Magento API. I’d get all the Magento & NetSuite products and match them in the getInputData method, passing whatever adds/updates/deletes were required to keep the data in sync to the Map method. Here is an example of reading all products from Magento.

I hope this helps clarify what is required to move data between NetSuite and Magento. It is a cheat sheet that I will refer back to myself so as not to forget lessons learned in my company’s move to Magento.

Leave a comment