Skip to content

Magento V2 Stock Item XML

The XML format documented here is used to update stock levels in Magento, via the Update Inventory in Magento V2 task.

Only sku and the fields you want to change need to be sent. Where a field has a matching use_config_* field, that field must be set to false before Magento will use the value you send instead of the store configuration.

Stock can also be sent as part of a product import, see Magento V2 Product XML. If your store uses Multi Source Inventory, use Magento V2 Source Item XML instead.

Sample XML

<?xml version="1.0" encoding="utf-8"?>
<ArrayOfStockItem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <StockItem>
    <sku>24-MB01</sku>
    <qty>198.00000</qty>
    <is_in_stock>true</is_in_stock>
    <manage_stock>true</manage_stock>
    <use_config_manage_stock>false</use_config_manage_stock>
    <backorders>0</backorders>
    <use_config_backorders>false</use_config_backorders>
  </StockItem>
</ArrayOfStockItem>

Stock Item

Magento Field XML Field Type Input Notes
SKU sku string Required The SKU of the product to update. The product must already exist in Magento
Quantity qty decimal Optional
Stock Status is_in_stock bool Optional
- item_id int Optional
- product_id int Optional
- stock_id int Optional
Qty Uses Decimals is_qty_decimal bool Optional
Display Out of Stock Message show_default_notification_message bool Optional Send true or false. An empty element will fail to parse
Out-of-Stock Threshold min_qty decimal Optional Set use_config_min_qty to false to use this value
- use_config_min_qty bool Optional
Minimum Qty Allowed in Cart min_sale_qty decimal Optional Set use_config_min_sale_qty to 0 to use this value
- use_config_min_sale_qty int Optional 0 for false, 1 for true. Unlike the other use_config_* fields, this one is numeric
Maximum Qty Allowed in Cart max_sale_qty decimal Optional Set use_config_max_sale_qty to false to use this value
- use_config_max_sale_qty bool Optional
Backorders backorders int Optional Valid values are listed below. Set use_config_backorders to false to use this value
- use_config_backorders bool Optional
Notify for Quantity Below notify_stock_qty decimal Optional Set use_config_notify_stock_qty to false to use this value
- use_config_notify_stock_qty bool Optional
Qty Increments qty_increments decimal Optional Set use_config_qty_increments to false to use this value
- use_config_qty_increments bool Optional
Enable Qty Increments enable_qty_increments bool Optional Set use_config_enable_qty_inc to false to use this value
- use_config_enable_qty_inc bool Optional
Manage Stock manage_stock bool Optional Set use_config_manage_stock to false to use this value
- use_config_manage_stock bool Optional
- low_stock_date string Optional
Can be Divided into Multiple Boxes for Shipping is_decimal_divided bool Optional
- stock_status_changed_auto int Optional
  • backorders - Valid values:
Value Meaning
0 No Backorders
1 Allow Qty Below 0
2 Allow Qty Below 0 and Notify Customer

Common Fields

The following fields are supported on every record we import into Magento. They are used by Zynk rather than sent to Magento.

XML Field Type Input Notes
external_id string Optional The unique ID of the record in the external system. Stored in Zynk's internal DB and used to track records already imported. Required when the Prevent Reprocessing setting is enabled on the task
store_code string Optional The store view code to send this record to, overriding the Store View Code setting on the task for this record only
match element Optional Match an existing record on a field and value other than the default. See Matching Records in Magento v2
matches element Optional As match, but matching on more than one field. See Matching Records in Magento v2

Errors

Records which fail to import are written to the Fail File in the same format as the input file, with the reason for the failure added in an errors element. There is no need to send this element yourself.

The name of each error tells you at which stage the record failed:

Name Meaning
Pre-Validation Zynk checked the record before sending it and found a problem, e.g. a required field is missing or a related record could not be found. The record was not sent to Magento
Prevent Reprocessing A record with the same external_id has already been imported, and the Prevent Reprocessing setting is enabled on the task
Error Magento rejected the record, or Zynk could not match the record to the data already in Magento. The description contains the message returned by Magento
Upload Error An unexpected error occurred while sending the record to Magento
<StockItem>
  <sku>24-MB99</sku>
  <errors>
    <error>
      <name>Error</name>
      <description>The product that was requested doesn't exist. Verify the product and try again.</description>
    </error>
  </errors>
</StockItem>