Task
The supplier XML feed sends delivery time as text: 3-5 days, 14 days, sometimes on request. The catalog needs a numeric lead time for filtering and sorting.
Short answer
Open the delivery_time value settings and add a rule: condition Regular expression, value \d+ (finds one or more digits in a row), action Remove everything except.
How to do it in Eofferix
Open the
delivery_timevalue settings in the XML editor.
The animation opens the XML node value settings, not the whole offerelement.Add a rule: condition
Regular expression, value\d+(finds one or more digits in a row), actionRemove everything except.
The rule keeps the first number found and removes the text unit. Save the settings and test values with a range, a single number, and text without a number.
Before / after
Before
source data<catalog>
<offers>
<offer id="4001"><sku>SKU-4001</sku><name>Hudson lamp</name><delivery_time>3-5 days</delivery_time><stock>12</stock></offer>
<offer id="4002"><sku>SKU-4002</sku><name>Parker chair</name><delivery_time>14 days</delivery_time><stock>4</stock></offer>
</offers>
</catalog>After
result<catalog>
<offers>
<offer id="4001"><sku>SKU-4001</sku><name>Hudson lamp</name><delivery_time>3</delivery_time><stock>12</stock></offer>
<offer id="4002"><sku>SKU-4002</sku><name>Parker chair</name><delivery_time>14</delivery_time><stock>4</stock></offer>
</offers>
</catalog>What to keep in mind
- For a range such as
3-5 days, this rule keeps the first number:3. If you need the maximum time, use a separate expression for the number after the dash. - For values without a number, such as
on request, add a replacement rule or an export condition. - This works well for large XML feeds where delivery time must become a numeric catalog field.