Stock synchronization for Magento 2
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 name | Example value | Description |
|---|---|---|
| Location internal id | 1 | 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:
|
| Saved Stock search internal id | 12 | See below |
| Page size for the saved search query | 500 | The 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 minutes | 360 | This value defines the frequency of the updates. Based on your catalog size, you can tweak this up or down |
| Stock stored at location level? | Yes | While 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/Custom | When 'Standard' is selected - 'Standard quantity field name' will be used, otherwise - 'Quantity field name' |
| Quantity field name | custitem_web_inventory | The 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 items | Yes | If 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 products | Yes | If 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.
No comments to display
No comments to display