# Products

*NOTE: This describes* [*schema version 1.7*](https://mbintegrationdataprod.blob.core.windows.net/schemas/mediablob-v1.7.xsd)*.*

A product has codes, texts and pictures. The texts and pictures can be defined for multiple languages. For each product a set of complement products can also be defined.

*Note that all used languageCodes must be registered on the account used to upload the information to Mediablob. Please check your account details with your Shoppa representative if you are unsure.*

Lets build a product from scratch and see how different requiements evolve its xml definition.

## A basic product

Lets say our customerId is *1143* and we have a product with only some basic information:

* **brand**: Orrefors
* **name**: Champagneglas
* **sku**: 65467-14
* **ean code**: 123456789012

This corresponding xml format is:

```markup
<mediablob customerID="1143" customerIDType="ShoppaID" createDate="2018-05-12T00:00:00" schemaVersion="1.7" xmlns="http://shoppa.com/mediablobSchema">
  <products>
    <product id="65467-14" idType="Code1">
      <codes>
        <code name="EAN13" value="123456789012" />
      </codes>
      <texts>
        <text productName="Champagneglas" brand="Orrefors" languageCode="sv-SE" />
      </texts>
    </product>
  </products>
</mediablob>
```

A product must always have at least one `text` section. Brand and name are required for new products. In the example above the product is described in the Swedish language.

## Extending the product information

We extend the product with additional sales arguments and a unit for prices:

* **short sales argument**: Exklusivt tvåpack. En perfekt bröllopspresent.
* **long sales argument**: Efva Attling är en juveldesigner som har använt sin rika erfarenhet och expertis för att skapa glaskonst. Hennes tredje glas är ett maskulint martiniglas med en silverring.
* **unit**: st

The xml for describing the product now becomes:

```markup
<mediablob customerID="1143" customerIDType="ShoppaID" createDate="2018-05-12T00:00:00" schemaVersion="1.7" xmlns="http://shoppa.com/mediablobSchema">
  <products>
    <product id="65467-14" idType="Code1">
      <codes>
        <code name="EAN13" value="123456789012" />
      </codes>
      <texts>
        <text productName="Champagne glass" brand="Orrefors" languageCode="sv-SE">
          <field name="sashort">Exklusivt tvåpack &amp; en perfekt bröllopspresent.</field>
          <field name="salong">Efva Attling är en juveldesigner som har använt sin rika erfarenhet och expertis för att skapa glaskonst. Hennes tredje glas är ett maskulint martiniglas med en silverring.</field>
          <field name="unit">st</field>
        </text>
      </texts>
    </product>
  </products>
</mediablob>
```

*To protect content against xml formatting constraints, the* `&` *character is xml encoded. This follows the xml specification and must be used for any content.*

## Additional languages

We decide to support English too. The xml gets extended with an additional `<text />` section. We also start the product with a generic language text `xx` with generic text for all languages unless overridden.

*Even without actual such texts, we recommend always including a row for xx to prevent duplicate products in the future.*

```markup
<mediablob customerID="1143" customerIDType="ShoppaID" createDate="2018-05-12T00:00:00" schemaVersion="1.7" xmlns="http://shoppa.com/mediablobSchema">
  <products>
    <product id="65467-14" idType="Code1">
      <codes>
        <code name="EAN13" value="123456789012" />
      </codes>
      <texts>
        <text productName="Champagne glass" brand="Orrefors" languageCode="xx"></text>
        <text productName="Champagne glas" languageCode="sv-SE">
          <field name="sashort">Exklusivt tvåpack &amp; en perfekt bröllopspresent.</field>
          <field name="salong">Efva Attling är en juveldesigner som har använt sin rika erfarenhet och expertis för att skapa glaskonst. Hennes tredje glas är ett maskulint martiniglas med en silverring.</field>
          <field name="unit">st</field>
        </text>
        <text productName="Champagne glass" languageCode="en-GB">
          <field name="sashort">Exclusive Twin-pack &amp; the perfect wedding present.</field>
          <field name="salong">Efva Attling is a designer of jewellery who has now brought her considerable experience and skills to the creation of glass. The third glass of the collection is a more masculine martini glass whose silver ring, though slightly sterner than its cousins, expresses the same warm sentiments.</field>
          <field name="unit">item</field>
        </text>
      </texts>
    </product>
  </products>
</mediablob>
```

## Extra codes

In some cases an article can have multiple codes of the same code type. For example, multiple EAN codes from different suppliers that are bound to the same article.\
In this case you can add on extra codes to the code field so that you can search for either one of them to get a match on the product.

```
<mediablob customerID="1143" customerIDType="ShoppaID" createDate="2018-05-12T00:00:00" schemaVersion="1.7" xmlns="http://shoppa.com/mediablobSchema">
  <products>
    <product id="65467-14" idType="Code1">
      <codes>
        <code name="EAN13" value="123456789012">
          <extra>123456789013</extra>
          <extra>123456789014</extra>
          <extra>123456789015</extra>
        </code>
      </codes>
      <texts>
        <text productName="Champagne glass" brand="Orrefors" languageCode="xx"></text>
        <text productName="Champagne glas" languageCode="sv-SE">
          <field name="sashort">Exklusivt tvåpack &amp; en perfekt bröllopspresent.</field>
          <field name="salong">Efva Attling är en juveldesigner som har använt sin rika erfarenhet och expertis för att skapa glaskonst. Hennes tredje glas är ett maskulint martiniglas med en silverring.</field>
          <field name="unit">st</field>
        </text>
        <text productName="Champagne glass" languageCode="en-GB">
          <field name="sashort">Exclusive Twin-pack &amp; the perfect wedding present.</field>
          <field name="salong">Efva Attling is a designer of jewellery who has now brought her considerable experience and skills to the creation of glass. The third glass of the collection is a more masculine martini glass whose silver ring, though slightly sterner than its cousins, expresses the same warm sentiments.</field>
          <field name="unit">item</field>
        </text>
      </texts>
    </product>
  </products>
</mediablob>
```

## Picture support

Finally, we add pictures to the swedish brand and productName fields. English users do not get to see any pictures for now.

```markup
<mediablob customerID="1143" customerIDType="ShoppaID" createDate="2018-05-12T00:00:00" schemaVersion="1.7" xmlns="http://shoppa.com/mediablobSchema">
  <products>
    <product id="65467-14" idType="Code1">
      <codes>
        <code name="EAN13" value="123456789012" />
      </codes>
      <texts>
        <text productName="Champagne glass" brand="Orrefors" languageCode="xx"></text>
        <text productName="Champagne glass" brand="Orrefors" languageCode="sv-SE">
          <field name="sashort">Exklusivt tvåpack &amp; en perfekt bröllopspresent.</field>
          <field name="salong">Efva Attling är en juveldesigner som har använt sin rika erfarenhet och expertis för att skapa glaskonst. Hennes tredje glas är ett maskulint martiniglas med en silverring.</field>
          <field name="unit">st</field>
        </text>
        <text productName="Champagne glass" brand="Orrefors" languageCode="en-GB">
          <field name="sashort">Exclusive Twin-pack &amp; the perfect wedding present.</field>
          <field name="salong">Efva Attling is a designer of jewellery who has now brought her considerable experience and skills to the creation of glass. The third glass of the collection is a more masculine martini glass whose silver ring, though slightly sterner than its cousins, expresses the same warm sentiments.</field>
          <field name="unit">item</field>
        </text>
      </texts>
      <pictures>
        <picture countryCode="se" languageCode="sv-SE" fieldName="brand" hashCode="a18deaa4383718cefc1a643f49e37607" />
        <picture countryCode="se" languageCode="sv-SE" fieldName="productName" hashCode="4b70b9000951a15db2ba6e61f05c3158" />
      </pictures>
    </product>
  </products>
</mediablob>
```

As you can see, the pictures are referenced by a hashCode. What hashCode to use will be described in detail in the Pictures section.

*Pictures require a* `countryCode`*. This is a legacy construct and is easily created by lowercasing the last two characters of the languageCode.*

### Reference a picture by its md5 hash

The hashCode returned from the picture uploader is based on md5, but formatted as a guid. The difference is big or little endianess. If you prefer to reference the picture by its md5 code, you can use the `md5` attribute instead:

```markup
<mediablob customerID="1143" customerIDType="ShoppaID" createDate="2018-05-12T00:00:00" schemaVersion="1.7" xmlns="http://shoppa.com/mediablobSchema">
  <products>
    <product id="65467-14" idType="Code1">
      <pictures>
        <picture countryCode="se" languageCode="sv-SE" fieldName="brand" md5="a4ea8da13738ce18fc1a643f49e37607" />
      </pictures>
    </product>
  </products>
</mediablob>
```

### Reference a picture with a public uri

Instead of referencing an image by hashCode or md5, you can provide a public uri from where Mediablob can download the picture for you. Mediablob will only use the same uri once, so you must ensure the uri is unique for each picture. Avoid using this scheme unless you are using a picture database that ensure unique uri's per picture.

```markup
<mediablob customerID="1143" customerIDType="ShoppaID" createDate="2018-05-12T00:00:00" schemaVersion="1.7" xmlns="http://shoppa.com/mediablobSchema">
  <products>
    <product id="65467-14" idType="Code1">
      <pictures>
        <picture countryCode="se" languageCode="sv-SE" fieldName="brand" uri="http://www2.mediablob.com/images/mediablob.png" />
      </pictures>
    </product>
  </products>
</mediablob>
```

*In the sample above, Mediblob would keep using the original downloaded picture even if the content of the uri changes.*


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://shoppa.gitbook.io/knowledge-hub/api-documentation/xml-structure/product.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
