Supplier catalogs

How to take stock from a JSON warehouses array by warehouse_id

2026-06-29
Task

Each JSON product has a warehouses array. The import needs stock only from warehouse ny-main, while reserve warehouses must not fill this field.

Short answer

Open qty inside warehouses and add a condition on neighboring warehouse_id: regular expression ^ny-main$ (matches a value that is exactly ny-main).

How to do it in Eofferix

  1. In the JSON snapshot, select qty inside the warehouses array.

    JSON field qty
    The selected field belongs to one warehouse object.
  2. Open the value settings.

    Opening qty settings
    The animation shows opening the field settings.
  3. Add an export condition: warehouse_id ^ny-main$.

    JSON condition
    The condition selects the warehouse before exporting the value.

Before / after

Before

source data
{
    "products": [
        {
            "sku": "SKU-25001",
            "name": "Hudson lamp",
            "warehouses": [
                {
                    "warehouse_id": "ny-main",
                    "qty": 14
                },
                {
                    "warehouse_id": "la-reserve",
                    "qty": 6
                }
            ]
        },
        {
            "sku": "SKU-25002",
            "name": "Parker chair",
            "warehouses": [
                {
                    "warehouse_id": "ny-main",
                    "qty": 0
                },
                {
                    "warehouse_id": "la-reserve",
                    "qty": 5
                }
            ]
        }
    ]
}

After

result
{
    "products": [
        {
            "sku": "SKU-25001",
            "name": "Hudson lamp",
            "stock": 14
        },
        {
            "sku": "SKU-25002",
            "name": "Parker chair",
            "stock": 0
        }
    ]
}

What to keep in mind

  • If the warehouse ID is always exact, use equals without a regular expression.
  • If the needed warehouse_id is missing, the resulting stock field will stay empty for that product.

Process data faster with Eofferix

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

Sign up