Skip to content

Magento V2 Source Item XML

The XML format documented here is used for the import of source items into Magento, via the Import Source Items to Magento V2 task.

Source items hold the stock level of a product at a single Multi Source Inventory source, so one product will have one source item per source it is stocked at. If your store does not use Multi Source Inventory, use Magento V2 Stock Item XML instead.

Sample XML

<?xml version="1.0" encoding="utf-8"?>
<ArrayOfSourceItem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <SourceItem>
    <sku>24-MB01</sku>
    <source_code>default</source_code>
    <quantity>198</quantity>
    <status>1</status>
  </SourceItem>
</ArrayOfSourceItem>

Source 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
Source source_code string Required The code of the Magento source holding the stock, e.g. default. Use Export Source Items to see the source codes in use on your store
Quantity quantity decimal Required
Status status int Optional Valid values are listed below
  • status - Valid values:
Value Meaning
0 Out of Stock
1 In Stock

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
<SourceItem>
  <sku>24-MB01</sku>
  <source_code>warehouse_1</source_code>
  <errors>
    <error>
      <name>Pre-Validation</name>
      <description>An inventory source with code 'warehouse_1' was not found in Magento.</description>
    </error>
  </errors>
</SourceItem>