Skip to content

Magento V2 Amasty Company XML

The XML format documented here is used for the import of companies into the Amasty B2B Company Account extension for Magento, via the Import Amasty Companies to Magento V2 task.

For the B2B features built into Adobe Commerce, see Magento V2 Company XML instead.

Every company needs a company admin, which is an existing Magento customer. Identify them with super_user_id or customer_email, or send a customer element to have Zynk create the customer as part of the import.

Sample XML

<?xml version="1.0" encoding="utf-8"?>
<ArrayOfAmastyCompany xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <AmastyCompany>
    <external_id>ZYNK0001</external_id>
    <company_id>2</company_id>
    <company_name>Zynk Software Ltd</company_name>
    <status>0</status>
    <company_email>[email protected]</company_email>
    <tax_vat_id>1</tax_vat_id>
    <street>
      <string>Office 16</string>
      <string>6 Charlotte Square</string>
    </street>
    <city>Newcastle</city>
    <postcode>NE1 4XF</postcode>
    <country_id>GB</country_id>
    <telephone>0191 123 4567</telephone>
    <customer_group_id>1</customer_group_id>
    <super_user_id>2</super_user_id>
    <customer_ids>
      <int>3</int>
    </customer_ids>
    <restricted_payments>
      <string>1</string>
    </restricted_payments>
    <use_company_group>true</use_company_group>
    <credit>
      <balance>50</balance>
      <issued_credit>100</issued_credit>
      <be_paid>0</be_paid>
      <currency_code>GBP</currency_code>
      <overdraft_allowed>false</overdraft_allowed>
      <overdraft_limit>0</overdraft_limit>
    </credit>
  </AmastyCompany>
</ArrayOfAmastyCompany>

Amasty Company

Magento Field XML Field Type Input Notes
ID company_id int Optional The Amasty company ID. When supplied, the company with this ID is updated
Company Name company_name string Required Also used for matching existing companies when no company_id is supplied
Status status int Optional The company status, as defined by the Amasty extension. See the Amasty B2B Company Account API documentation
Company Email company_email string Required
VAT/TAX ID tax_vat_id int Optional Note that the Amasty extension holds this as a number, unlike the Adobe Commerce vat_tax_id field
Street Address street/string string Required One string element per address line
City city string Required
Zip/Postal Code postcode string Required
Country country_id string Required The two letter ISO country code, e.g. GB
Phone Number telephone string Required
Customer Group customer_group_id int Optional Use instead of customer_group_code
Customer Group customer_group_code string Optional The code of the customer group, e.g. Wholesale. Zynk looks the group up in Magento. Use instead of customer_group_id
Use Company Group use_company_group bool Optional Set to true to put all customers of the company into the company's customer group
Company Administrator super_user_id* int Conditional The Magento customer ID of the company admin
Company Administrator customer_email* string Conditional The email address of an existing Magento customer to use as the company admin
Company Administrator customer* element Conditional A full customer record to create and use as the company admin, in the Magento V2 Customer XML format
Company Users customer_ids/int int Optional The Magento customer IDs of the other members of the company
Sales Representative sales_representative_id int Optional The Magento admin user ID of the sales representative
Restricted Payment Methods restricted_payments/string string Optional One string element per restricted payment method
Reject Reason reject_reason string Optional
  • super_user_id*, customer_email*, customer* - A company must have an administrator. Send one of these to set it

Credit

The company credit terms, sent in a credit element.

Magento Field XML Field Type Input Notes
- id int Optional
- company_id int Optional
Balance balance decimal Optional
Issued Credit issued_credit decimal Optional
To Be Paid be_paid decimal Optional
Currency currency_code string Optional e.g. GBP
Allow Overdraft overdraft_allowed bool Optional
Overdraft Limit overdraft_limit decimal Optional
Overdraft Repayment Period overdraft_repay decimal Optional
Overdraft Repayment Period Value overdraft_repay_digit decimal Optional
Overdraft Repayment Period Type overdraft_repay_type int Optional
Overdraft Penalty overdraft_penalty decimal Optional

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
<AmastyCompany>
  <company_name>Zynk Software Ltd</company_name>
  <customer_email>[email protected]</customer_email>
  <errors>
    <error>
      <name>Pre-Validation</name>
      <description>There was more than one customer found with email '[email protected]'.</description>
    </error>
  </errors>
</AmastyCompany>