Example 2

Example 2 #

fn getActive() {
  if (number(src("variant: inventory quantity")) > 0) {
    return "1";
  } else {
    return "0";
  }
}

fn getWeight() {
  if (src("variant: weight unit") == "kg") {
    return number(src("variant: weight")) * 1000;
  } else {
    return src("variant: weight unit");ex
  }
}

fn getSeason() {
  if (
    contains(src("tags"), "Winter") ||
    contains(src("tags"), "Autumn")
  ) {
    return "Autumn-winter";
  } else if (
    contains(src("tags"), "Spring") ||
    contains(src("tags"), "Summer")
  ) {
    return "Spring-summer";
  } else {
    return "Never out of season";
  }
}

sello "ahlens active #1234" = getActive();
sello "brand" = src("vendor");
sello "group type" = "size";
sello "images" = src("images");
sello "manufacturer" = src("vendor");
sello "private name" = src("title");
sello "property ColorText" = src("option Color");
sello "property EAN" = src("variant: barcode");
sello "property Gender" = "Woman";
sello "property MiintoMaterialComposition" = src("metadata: quality") || regexFirstMatch(src("body html"), "Quality: (.+)<");
sello "property MiintoSeason" = getSeason();
sello "property SizeName" = src("option Size");
sello "property Tags" = src("tags");
sello "quantity" = src("variant: inventory quantity");
sello "sku" = src("variant: sku");
sello "source category" = src("product type");
sello "standard description en" = src("body html");
sello "standard name en" = src("title");
sello "weight" = getWeight();

splitMaterial("M_197_0_material", "M_197_0_material_percentage", src("metdata: quality") || regexFirstMatch(src("body html"), "Quality: (.+)<"));