Supplier catalogs

How to sum warehouse stock values in a supplier XML feed

2026-06-29
Task

The supplier XML contains several warehouses inside one offer: warehouse/stock for north and south locations. The import needs a single total stock_total.

Short answer

Open the stock_total value settings and add a sum rule for {/catalog/offers/offer/warehouse/stock}. Eofferix will add all stock values inside the current item.

How to do it in Eofferix

  1. In the XML snapshot, select the stock_total value inside the repeated offer.

  2. Open the value settings.

    Opening stock_total in XML
    The animation shows selecting the field that receives the total stock.
  3. Add a rule: condition Any value, action Sum values, source {/catalog/offers/offer/warehouse/stock}.

    stock_total sum rule
    The rule sums warehouse stock values for the current item.

Before / after

Before

source data
<catalog>
  <offers>
    <offer id="2001">
      <sku>SKU-2001</sku><name>Hudson lamp</name>
      <warehouse code="north"><stock>4</stock></warehouse>
      <warehouse code="south"><stock>8</stock></warehouse>
      <stock_total>0</stock_total>
    </offer>
    <offer id="2002">
      <sku>SKU-2002</sku><name>Parker chair</name>
      <warehouse code="north"><stock>0</stock></warehouse>
      <warehouse code="south"><stock>3</stock></warehouse>
      <stock_total>0</stock_total>
    </offer>
  </offers>
</catalog>

After

result
<catalog>
  <offers>
    <offer id="2001">
      <sku>SKU-2001</sku><name>Hudson lamp</name>
      <warehouse code="north"><stock>4</stock></warehouse>
      <warehouse code="south"><stock>8</stock></warehouse>
      <stock_total>12</stock_total>
    </offer>
    <offer id="2002">
      <sku>SKU-2002</sku><name>Parker chair</name>
      <warehouse code="north"><stock>0</stock></warehouse>
      <warehouse code="south"><stock>3</stock></warehouse>
      <stock_total>3</stock_total>
    </offer>
  </offers>
</catalog>

What to keep in mind

  • The sum should be scoped to the current offer, not the whole XML file.
  • If some warehouses must be excluded, add warehouse-code conditions first.
  • Keep a technical start value such as 0 in stock_total so the field is easy to select in the snapshot.

Process data faster with Eofferix

Create a free account to automate catalogs and price lists around your own rules.

Sign up