Proposal summary
This proposal details how the integration between NetSuite and Magento is handled and also the full plan of the integration.
Requirement
The overview scope of the NetSuite-Magento integration as follows:
- Item SYNC from NetSuite to Magento
- Item Inventory SYNC(Stock Update) from NetSuite to Magento
- Customer SYNC from Magento to NetSuite
- Order SYNC from Magento to NetSuite
- Item Fulfillment/Shipment SYNC
- Invoice SYNC from Magento to NetSuite
- RMA/Credit Refund SYNC
Our Solution
NetSuite is the best option for the inventory and order management software and Magento is the best option for the eCommerce Software. For the Smooth process of a business, the two platforms need to be integrated. So we need to develop a connector the SYNC between NetSuite and Magento
We can use two types of WEB APIs for the Magento: SOAP API and REST API.
We are planning to develop the NetSuite-Magento Connector using the REST APIs. So REST API is the preferred option to implement the NetSuite-Magento Connector
The Connector will send to and fro data from NetSuite and Magento.
The first step for the integration is to complete the mappings between NetSuite and Magento. The mapping should be done for the Items, Customer and Contacts, Sales Order, Invoice, Item Fulfillment, Cash Refund/Credit Memo. The mapping should be adjusted based on the client’s needs. Custom fields can be created on NetSuite and Magento.
Magento Authentication Setup
The next step is to do the authentication setup for the Magento which will have the authorization to use the Magento Rest API. The integration needs to be created in Magento Admin Console and which has been already created: NetSuite-Magento Integration. The credentials for the integration can be retrieved from the Magento Admin console.
There are three authentication methods available when using the Web API: token-based, OAuth-based, and session-based. The preferred method for the authentication can be OAuth-based which is suitable for the integration but token-based also be preferable.
Token-Based Authentication is for the mobile application but for the integration Oauth based authentication is good to use. A Script library should be created for the Oauth authentication
Store the Credentials in the custom record so that suite scripts can fetch the credentials from the custom record. This setup allows us to change the credentials only in the custom record and no change is required in the suite scripts when the credentials are changed
Reference: https://inviqa.com/blog/magento-2-tutorial-overview-web-api
NetSuite Authentication Setup
Restlets scripts are also needed for the Netsuite-Magento Connector. So Integration records and access tokens need to be generated for the role on the NetSuite Side. The credentials will be used for the Magento codes and will be used for NetSuite Restlet API authentication. Token-based authentication is the preferred and easiest way for the Restlet API authentication. Following need to cr created:
- Integration Record
- Custom Role
- Access Tokens
Item SYNC from NetSuite to Magento
- Creation of Items
- We need a check box on the item Record “Sync to Magento” when the box is checked the item should be created and set in the production Magento. When the checkbox is unchecked, then the item should not be synced to the Magento. Based on the checkbox user has the option to display the items on the Magento website.
- For the item Sync, we need to consider only the Inventory items
- When an item is created in the NetSuite, the same item should be automatically synced into the Magento with correct details.
- User event script must be developed for the real-time sync
- Master items and subitems need to be considered. Need to consider Master Item then you need to consider the Sub Item is the variation. The master item in the Netsuite is the parent product in the Magento and the sub-items will be the product variations.
- Before the script development field mapping should be confirmed.
- Multiple images will be there for the items – 6 custom fields should be created for the images. Need to consider all the custom fields for the image sync for the items.
- Need to create the item variation type custom field in the item record. The field type is a list and the values of the field may be Color, Flavour, Size, etc… This field determines the attribute for the master items. This field can be used for the creation of a product and its configuration in the Magento. Whenever a product has its variations, Magento needs an attribute and so the same custom field can be used for the attribute.
- Category sync needs to be considered when the item creation.
- Need to create 2 custom fields in the NetSuite for the Category and Sub-Category. The field type will be a list.
- The new category can be added from the NetSuite side.
- Based on the category selected in the item, the script should check whether the category is present in the Magento and if yes directly add the item into the corresponding category and if not present the new category need to be created in the Magento and then add the item into the new category
- Category API can be used for the category creation and adding of items into the category
- Pricing details for the item will be sent by the Client.
- Following should be considered for the quantity:
- If the item is a regular item, then the location that is considered for the quantity is Online Store. This location is not yet created and will be created by the client
- If the item is a non-regular item, then the location that is considered for the quantity is Main Warehouse Store.
- There is a field for determining the regular item and non-regular item: Regular Item
- Tax Setup
- In NetSuite, the price will be stored without Tax.
- Tax will be applied for the item in the NetSuite by adding the Tax Schedule. The only tax available now is VAT which is 5%.
- For the Retail/individual customers, the tax will be inclusive in the price and for the commercial customers, the tax will be excluded from the price.
- Item Unit needs to be synced into the Magento.
- A new custom tab needs to be created in the item record and should be called Magento. All the custom fields related to the MAgento integration need to be present under the new tab: Magento
- Magento API can be used for product creation.
- When an item is successfully synced, then the corresponding Magento Item Id should be stored in the item record. A custom field can be used in the item record for storing the Magento product id.
- Updation of Items
- When an item is updated on the NetSuite Side, then the same changes should be effected on the Magento Side.
- Only the changes need to be synced.
- Category sync should also consider for the item updation sync
- Need to compare the old record and new record object in the user event script for identifying the changes in the item record.
- Product and its variations should be correctly synced.
- Deletion of Items
- When a master item is deleted, then the corresponding main product should be deleted.
- When a sub-item is deleted then the corresponding Magento product should be deleted.
- Map- Reduce Script For the Already Existing Items
- A map-reduce script needs to be developed for the sync of already existing items in the NetSuite. All the existing items that are not synced to the Magento need to be synced to the Magento. Standard Magento item Create API call can be used for the item creation in the Magento. After the successful creation of the item, in the Magento, the Magento item Id should be stored in the item record. This needs to be used for the item update sync from NetSuite to Magento.
- Stock Update For the Item
- Whenever the stock is updated in the NetSuite account, the quantity should be synced to the Magento for the items.
- In NetSuite, the stock will be updated due to various records. So need to consider all the records that cause stock updates.
- A common user event script can be used for all the records and sync should be happening in real-time.
Customer SYNC FROM Magento To NetSuite
- Creation of Customer
- When a customer is created in Magento, then the same customer needs to be created in the NetSuite.
- Need to create a restlet script and customer details will be sent to the restlet script. A post-action needs to be done with the restlet script. Restlet script should create the customer based on the body details send from the Magento
- Before the development of the restlet script, please create a JSON object for the Customer details based on the Magento customer details. This JSON object structure should contain all the required details for the customer. This will be a JSON object structure that will be sent by the Magento side when the customer is created. Magento Team will use this same JSON structure for sending the customer details.
- Based on the JSON structure object, the customer should be created in the NetSuite.
- The expected output should be when a customer is created in Magento, the Magento will send a POST action call to the RESTLET script along with the JSON object that contains the Magento customer details and the customer will create the customer record.
- In Magento, there are two types of customer: Retail and Wholesale
- For the Retail and Wholesale customers, customers can be directly created in Netsuite.
- The Magento Id Should be stored in the Netsuite customer record.
- On the successful creation of a customer in NetSuite, store the customer internal id of the customer into the Magento Customer. For that need do an update API call for the customer
- Approval for Email Confirmation
- A custom field “Email for Account Confirmation” field should be created in both NetSuite and Magento
- For the Retail customer, the Email for Account Confirmation field will be checked automatically on creation for both Magento and NetSuite.
- For the Wholesale customer, the Email for Account Confirmation field will be unchecked on the creation for both Magento and NetSuite.
- A button needs to be created on the wholesalers customers in Netsuite for approval. When the user clicks the approval button then the Email for Account Confirmation field should be checked and this should be reflected into Magento by calling the standard API for the Magento Customer Update mentioning that the Email for Account Confirmation should be checked.
- Updation of Customer
- Whenever a customer is updated in Magento, the same should be reflected in the NetSuite also.
- A Restlet script needs to be developed for the Customer Update.
- Magento Team will call the restlet script when the customer is updated in the Magento and JSON object structure will be the same as used in the creation of customers.
- A POST action should be done for the Restlet script and the action would be the customer update based on the JSON object sent by Magento. In the Object, Netsuite Customer internal id and Magento customer id will be available.
- “Email for Account Confirmation” field also syncs correctly between Magento and NetSuite.
- Deletion of Customer
- When a customer is deleted from Magento, a call will be sent to NetSuite for the deletion of the customer. For that need to create Restlet script and action should be the deletion of the customer. The details of the customer to be deleted will be sent by Magento.
Error Handling should be done throughout the development. This can be done using a custom record and should be attached to the customer.
- Map- Reduce Script For the Already Existing Customers
- A map-reduce script needs to be developed for the sync of already existing customers in the NetSuite. All the existing customers that are not synced to the Magento need to be synced to the Magento. Standard Magento customer Create API call can be used for the customer creation in the Magento. After the successful creation of the customer in the Magento, the Magento customer Id should be stored in the customer record. This need to be used for the customer update sync from NetSuite to Magento
Magento API Reference: https://magento.redoc.ly/2.4.2-admin/tag/customers
Quote and Order SYNC from Magento to NetSuite
On Magento Website, items can be added to Quote and also to cart. There are two types of customers: Commercial customers and Individual/retailer customers. The commercial customer will add the items to the Quote. So such customers have the option to create the quote in the Magento. For the quote in the Megento, an estimate should be created in the NetSuite account. For the quote sync, a map-reduce script should be created and all the recent quotes should be fetched from the Magento and should be created estimate for each quote. The user will edit the quote in the NetSuite account and will adjust the price and quantity. On updating the Estimate in the NetSuite, the same update should be synced to the Magento Quote. For updating the Quote, need to create a user event script and should be deployed on the estimate records. On updating the quote, a notification should be sent to the customer so that they can check the quote with updated details. After the customer checked the quote and if they converted the quote to cart and placed the order, then an order will be created in the Magento. For such orders, the estimate in the NetSuite should be transformed to the Sales Order.
For the individual customers, the customer will add the items directly to the cart and place the orders. For such orders, need to create sales orders in the NetSuite.
A map-reduce script should be developed for the order sync. If the order is created from the quote then the script should find the corresponding estimate and should be transformed the estimate to the Sales Order. If the order doesn’t have any quote, then directly a sales order in the NetSuite. The sync is not real-time and the map-reduce script should fetch recently created orders and based on the orders need to create sales orders in the NetSuite.
A custom record setup should be used for backtracking the order sync. The customer, Estimate, Sales orders, sync response, the error should be stored on the custom record.
We can use the standard order API for the SYNC
Item Fulfillment SYNC
When an item fulfillment is created for the Magento Sales orders, then the shipment should be created in the Magento with details. A user event script can be used for the item fulfillment sync. The user may create the item fulfillment in the Netsuite account. Whenever the item fulfillment is created for the Magento orders, then the shipment should be created for the corresponding orders in the Magento.
If a tracking number is present in the item fulfillment record, that should also be synced into the Magento shipment
On the successful sync, the item fulfillment should be attached to the corresponding custom record.
Invoice SYNC
When an invoice is created in the NetSuite account, then the invoice should be created in the Magento with the details. A user event script can be used for the invoice sync. The user may create the invoice in the Netsuite account. Whenever the invoice is created for the Magento orders, then the invoice should be created for the corresponding orders in the Magento.
On the successful sync, the invoice should be attached to the corresponding custom record.
Payment SYNC
When the payment is received for the invoice then that needs to sync the Netsuite. Payment should be created in the NetSuite account should be applied to the Invoice. For the payment sync, Map-reduce can be used.
This sync should be applicable only if the payment method is cash. If the payment method is a card, then the order is already paid and then the user will create the payment and should be applied to the invoice.