Search code examples
xmlamazon-web-servicesamazon-mwsamazon-product-api

Amazon MWS Product Feed With Relationships


I am able to successfully upload my products to Amazon using this feed.xml file.

<?xml version="1.0" encoding="iso-8859-1"?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
  <Header>
    <DocumentVersion>1.01</DocumentVersion>
    <MerchantIdentifier>MERCHANTID</MerchantIdentifier>
  </Header>
  <MessageType>Product</MessageType>
  <PurgeAndReplace>false</PurgeAndReplace>
  <Message>
    <MessageID>1</MessageID>
    <OperationType>Update</OperationType>
    <Product>
      <SKU>56791</SKU>
      <StandardProductID>
        <Type>UPC</Type>
        <Value>1234567890</Value>
      </StandardProductID>
      <Condition>   
        <ConditionType>New</ConditionType>
      </Condition>
      <DescriptionData>
        <Title>Yougurt Covered Raisins 300</Title>
        <Brand>Valued Naturals</Brand>
        <Description>Quality you can see and taste</Description>
        <BulletPoint>Contains milk and soy</BulletPoint>
        <BulletPoint>Gluten Free</BulletPoint>
        <BulletPoint>Kosher</BulletPoint>
        <Manufacturer>IFood</Manufacturer>
        <ItemType>raisins</ItemType>
      </DescriptionData>
      <ProductData>
        <FoodAndBeverages>
          <ProductType>
            <Food>
              <VariationData>
                        <Parentage>parent</Parentage> 
                        <VariationTheme>Size</VariationTheme>
                        <Size>100</Size>
                    </VariationData>
              <UnitCount unitOfMeasure="GR">396</UnitCount>
            </Food>
          </ProductType>
        </FoodAndBeverages>
      </ProductData>
    </Product>
  </Message>

<Message>
    <MessageID>2</MessageID>
    <OperationType>Update</OperationType>
    <Product>
      <SKU>56791-300</SKU>
      <StandardProductID>
        <Type>UPC</Type>
        <Value>1234567890</Value>
      </StandardProductID>
      <Condition>   
            <ConditionType>New</ConditionType>
        </Condition>
      <DescriptionData>
        <Title>Yougurt Covered Raisins 300gr</Title>
        <Brand>Valued Naturals</Brand>
        <Description>Quality you can see and taste</Description>
        <BulletPoint>Contains milk and soy</BulletPoint>
        <BulletPoint>Gluten Free</BulletPoint>
        <BulletPoint>Kosher</BulletPoint>
        <Manufacturer>IFood</Manufacturer>
        <ItemType>raisins</ItemType>
      </DescriptionData>
      <ProductData>
        <FoodAndBeverages>
          <ProductType>
            <Food>
              <VariationData>
                <Parentage>child</Parentage> 
                <VariationTheme>Size</VariationTheme>
                <Size>100</Size>
              </VariationData>
              <UnitCount unitOfMeasure="GR">396</UnitCount>
            </Food>
          </ProductType>
        </FoodAndBeverages>
      </ProductData>
    </Product>
  </Message>
  <Message>
    <MessageID>3</MessageID>
    <OperationType>Update</OperationType>
    <Product>
      <SKU>56791-100</SKU>
      <StandardProductID>
        <Type>UPC</Type>
        <Value>1234567890</Value>
      </StandardProductID>
      <Condition>   
            <ConditionType>New</ConditionType>
        </Condition>
      <DescriptionData>
        <Title>Yougurt Covered Raisins 100gr</Title>
        <Brand>Valued Naturals</Brand>
        <Description>Quality you can see and taste</Description>
        <BulletPoint>Contains milk and soy</BulletPoint>
        <BulletPoint>Gluten Free</BulletPoint>
        <BulletPoint>Kosher</BulletPoint>
        <Manufacturer>IFood</Manufacturer>
            <ItemType>raisins</ItemType>
      </DescriptionData>
      <ProductData>
        <FoodAndBeverages>
          <ProductType>
            <Food>
              <VariationData>
                    <Parentage>child</Parentage> 
                    <VariationTheme>Size</VariationTheme>
                    <Size>100</Size>
                    </VariationData>
              <UnitCount unitOfMeasure="GR">100</UnitCount>
            </Food>
          </ProductType>
        </FoodAndBeverages>
      </ProductData>
    </Product>
  </Message>
</AmazonEnvelope> 

After the success message from amazon I had to post a request in order to define the relationships between the products to set the second and third product as a child of the first product which looks like this:

<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
  <Header>
    <DocumentVersion>1.01</DocumentVersion>
    <MerchantIdentifier>MYMERCHANTID</MerchantIdentifier>
  </Header>
  <MessageType>Relationship</MessageType>
  <PurgeAndReplace>false</PurgeAndReplace>

  <Message>
    <MessageID>1</MessageID>
    <OperationType>Update</OperationType>
    <Relationship>
      <ParentSKU>56791</ParentSKU>
      <Relation>
        <SKU>56791-300</SKU>
        <Type>Variation</Type>
      </Relation>
      <Relation>
        <SKU>56791-100</SKU>
        <Type>Variation</Type>
      </Relation>
    </Relationship>
  </Message>
</AmazonEnvelope>

Now I wonder if it is possible to define all these parent-child relationships within a single request, in example placing some extra data in the first feed.xml file ?


Solution

  • Sadly you can't. The MessageType must be unique within an AmazonEnvelope. One of your envelopes is of the type Product and the other of the type Relatonship.