Skip to main content

Stock synchronization for Magento 2

[missing screenshot: confluence_logo_new.png]

Stock synchronization is done by default once in 6 hours. At this time, all stocks will be grabbed from NetSuite and imported in Magento. 

The relevant stock settings can be found at System->NetSuite->Settings->Stock Options:

Parameter nameExample valueDescription
Location internal id1

NetSuite supports multiple stock locations (warehouses). Magento does not, so it is necessary to specify the location from where Magento will grab stocks.

In case you need to handle multiple locations:

  • if you are fine with updating stocks only once in a few hours (how often really depends on your catalog size, but assume 6h as a default), then you can create a saved search as described below. As long as you can express your stock as a single numeric value in a single column, we can use that
  • if you want to benefit from delta updates, then stock must exist globally at product or location level. Same location needs to be used for all products, so you might need to rely on suite scripts to update a specific virtual location.


Saved Stock search internal id12See below
Page size for the saved search query500The stock information is paged when grabbed. This value defines how many stock values are grabbed at once. 500 is the maximum NetSuite will allow
Update the stocks every N minutes360This value defines the frequency of the updates. Based on your catalog size, you can tweak this up or down
Stock stored at location level?YesWhile by default the stock information is present at location level, some users may choose to expose it as a custom field at product level. This flag instructs the connector on where to look for stock information

Quantity field type

Standard/CustomWhen 'Standard' is selected - 'Standard quantity field name' will be used, otherwise - 'Quantity field name'
Quantity field namecustitem_web_inventoryThe exact field name that contains the stock number. For fields at product level, only custom fields are accepted. For fields at location level you can specify either custom or standard fields. A new setting will appear, "Quantity field type", where you can define whether the field is standard or custom

Standard quantity field name

qty

Used when grabbing stock at product import. Must be an InventoryItemLocations standard field

Change stock status when under zero itemsYesIf this is set, then when stock becomes 0 status will get changed to "out of stock", then status will be changed to "in stock" when quantity is greater than zero. If this option is not set then status will always stay as "In stock". Useful when you allow backorders.
Grab stock updates when importing productsYesIf this is set to No, then the only stock update will be the full one, based on the saved search. You would want this when the stock is not stored in a single location and the saved search is the only way to easily aggregate stock into a single column.

Saved stock search

Since stock update is a frequent operation on all products, we wanted to make it as fast as possible. Instead of querying NetSuite for all product information then extracting the stock, a saved search must be created so to grab only the fields we care about. The saved search must contain only 2 fields (it can contain more but they will be ignored):

  • product internal id
  • the field that contains the stock number at was defined in the "Quantity field name" setting

If the "Quantity Field Name" is at location level, then you will be getting a row for each location. Mitigate this by adding a filter criteria to the search to list only the location you are grabbing from (the one that you defined in "Location internal id")

If you don't use stocks for specific product types (i.e. matrixes do not have stocks, only their subitems have), filter them out with criteria conditions. This way you will prevent unnecessary data processing.

Note that it is required to create the saved search as described above and put its internal NetSuite id inside the "Saved Stock search internal id" setting, stocks will not be imported otherwise.