Product Integration Examples
.NET code samples for importing product, on hand, and price data via the Norce Commerce Connect C# client library.
- GitHub: Storm.Connect.Contracts
- NuGet: Enferno.Services.StormConnect.Contracts
- Postman collection: Connect product examples
For integration patterns and field reference, see Product Import Guide and Working with the X-Stormconnect Header.
ImportProducts
View .NET code sample
// Using Storm Client library: https://github.com/StormCommerce/Storm.Connect.Contracts
// NuGet: https://www.nuget.org/packages/Enferno.Services.StormConnect.Contracts/
static void Main()
{
var serviceUrl = "https://demo.api-se.norce.tech/commerce/connect/4.0/";
var applicationId = 0;
var secretKey = Guid.NewGuid();
var job = ImportProduct(serviceUrl, applicationId, secretKey);
}
public static JobDto ImportProduct(string serviceUrl, int applicationId, Guid secretKey)
{
const int accountId = 0;
var productHeader = new ProductHeader()
{
AccountId = accountId,
FullFile = false,
ProductFieldsThatAreSet = new List<ProductField>()
{
ProductField.ManufacturerCode,
ProductField.Variants,
ProductField.Cultures,
ProductField.Categories
},
ProductCultureFieldsThatAreSet = new List<ProductCultureField>
{
ProductCultureField.Name,
ProductCultureField.Description,
ProductCultureField.Title
},
VariantFieldsThatAreSet = new List<VariantField>
{
VariantField.ManufacturerPartNo,
VariantField.Skus
},
VariantCultureFieldsThatAreSet = new List<VariantCultureField>
{
},
SkuFieldsThatAreSet = new List<SkuField>
{
SkuField.Status,
SkuField.Type,
SkuField.VatRate
},
SkuCultureFieldsThatAreSet = new List<SkuCultureField>
{
SkuCultureField.ErpName,
SkuCultureField.Comment
},
SkuPriceListFieldsThatAreSet = new List<SkuPriceListField>
{
},
IgnoreSkuPriceListFieldsWhenEmpty = new List<SkuPriceListField>
{
},
SkuStructureItemFieldsThatAreSet = new List<SkuStructureItemField>
{
}
};
var requestUri = new Uri(new Uri(serviceUrl), "product/ImportProducts");
var myRequest = new MyRequest<ProductHeader, Product>(productHeader, GetProducts());
return RestHelper.SendStreamedData<JobDto, ProductHeader, Product>(
requestUri.AbsoluteUri, applicationId, secretKey, myRequest);
}
private static IEnumerable<Product> GetProducts()
{
return new List<Product>
{
new Product
{
ManufacturerCode = "MFR0000001", // Required key
Variants = new List<Variant>
{
new Variant
{
ManufacturerPartNo = "MFRPARTNOTEST01", // Required key
Skus = new List<Sku>
{
new Sku
{
PartNo = "TESTSKU01", // Required key
Status = SkuStatus.Active, // Required
Type = SkuType.Standard, // Required
VatRates = new List<VatRate>
{
new VatRate
{
Rate = 25.00M,
SalesArea = SalesArea.Sweden
}
},
Cultures = new List<SkuCulture>
{
new SkuCulture
{
CultureCode = "sv-SE",
ErpName = "ERP Name",
Comment = "Comment"
}
}
}
}
}
},
Cultures = new List<ProductCulture>
{
new ProductCulture
{
CultureCode = "sv-SE",
Name = "Name",
Description = "Description",
Title = "Title"
}
},
Categories = new List<ProductCategory>
{
new ProductCategory
{
Code = "CAT001",
SortOrder = 1
}
}
}
};
}Setting parametrics
Parametrics are set through the same ImportProducts call, on the Product (product-level) or Variant (variant-level) entity — there is no separate parametric-import endpoint. Add ProductField.ProductParametrics and/or VariantField.VariantParametrics to the header's ProductFieldsThatAreSet/VariantFieldsThatAreSet, then include a Parametrics collection on the matching entity. The product/variant is still identified the normal way, via ManufacturerCode + ManufacturerPartNo.
Each ParametricValue is matched to an existing parametric definition by ParametricCode, and carries its value in the field matching the parametric's type (ValueText via Cultures, ValueBoolean, ValueDecimal, ValueInteger, ValueDateTime, or ValueList/MultipleValueList for list-type parametrics). The parametric definition itself — its code, type, and allowed list values — must already exist in Norce; see Metadata Integrations.
View .NET code sample
var productHeader = new ProductHeader()
{
AccountId = accountId,
FullFile = false,
ProductFieldsThatAreSet = new List<ProductField>()
{
ProductField.ManufacturerCode,
ProductField.Variants,
ProductField.ProductParametrics // product-level parametrics
},
VariantFieldsThatAreSet = new List<VariantField>
{
VariantField.ManufacturerPartNo,
VariantField.Skus,
VariantField.VariantParametrics // variant-level parametrics, e.g. color/size
},
SkuFieldsThatAreSet = new List<SkuField>
{
SkuField.Status,
SkuField.Type
}
};
var products = new List<Product>
{
new Product
{
ManufacturerCode = "MFR0000001", // Required key
ProductParametrics = new List<ParametricValue>
{
new ParametricValue
{
ParametricCode = "MATERIAL", // Text parametric
Cultures = new List<ParametricValueCulture>
{
new ParametricValueCulture { CultureCode = "sv-SE", ValueText = "Trä" },
new ParametricValueCulture { CultureCode = "en-GB", ValueText = "Wood" }
}
}
},
Variants = new List<Variant>
{
new Variant
{
ManufacturerPartNo = "MFRPARTNOTEST01", // Required key
VariantParametrics = new List<ParametricValue>
{
new ParametricValue
{
ParametricCode = "COLOR", // List-type parametric
ValueList = new ParametricValueList { Code = "RED" }
}
},
Skus = new List<Sku>
{
new Sku { PartNo = "TESTSKU01", Status = SkuStatus.Active, Type = SkuType.Standard }
}
}
}
}
};ImportOnHands
View .NET code sample
// Using Storm Client library: https://github.com/StormCommerce/Storm.Connect.Contracts
// NuGet: https://www.nuget.org/packages/Enferno.Services.StormConnect.Contracts/
static void Main()
{
var serviceUrl = "https://demo.api-se.norce.tech/commerce/connect/4.0/";
var applicationId = 0;
var secretKey = Guid.NewGuid();
var job = ImportSkuOnhand(serviceUrl, applicationId, secretKey);
}
public static JobDto ImportSkuOnhand(string serviceUrl, int applicationId, Guid secretKey)
{
const int accountId = 0;
var onhandHeader = new SkuOnhandHeader
{
AccountId = accountId,
FullFile = false,
SkuOnhandFieldsThatAreSet = new List<SkuOnhandField>()
{
SkuOnhandField.OnhandValue,
SkuOnhandField.IncomingValue,
SkuOnhandField.NextDeliveryDate,
SkuOnhandField.LeadTimeDayCount
}
};
var requestUri = new Uri(new Uri(serviceUrl), "product/ImportOnhands");
var myRequest = new MyRequest<SkuOnhandHeader, SkuOnhand>(onhandHeader, GetOnhands());
return RestHelper.SendStreamedData<JobDto, SkuOnhandHeader, SkuOnhand>(
requestUri.AbsoluteUri, applicationId, secretKey, myRequest);
}
private static IEnumerable<SkuOnhand> GetOnhands()
{
return new List<SkuOnhand>
{
new SkuOnhand
{
PartNo = "PartNo123", // Required key
WarehouseCode = "Warehouse1", // Required key
LocationCode = "Location1", // Required key
OnhandValue = 1.0M,
IncomingValue = 2.0M,
NextDeliveryDate = DateTime.Now.AddDays(2),
LeadTimeDayCount = null
}
};
}ImportSkuPriceLists
View .NET code sample
// Using Storm Client library: https://github.com/StormCommerce/Storm.Connect.Contracts
// NuGet: https://www.nuget.org/packages/Enferno.Services.StormConnect.Contracts/
static void Main()
{
var serviceUrl = "https://demo.api-se.norce.tech/commerce/connect/4.0/";
var applicationId = 0;
var secretKey = Guid.NewGuid();
var job = ImportSkuPriceList(serviceUrl, applicationId, secretKey);
}
public static JobDto ImportSkuPriceList(string serviceUrl, int applicationId, Guid secretKey)
{
const int accountId = 0;
var priceListHeader = new SkuPriceListHeader
{
AccountId = accountId,
FullFile = false,
SkuPriceListFieldsThatAreSet = new List<SkuPriceListField>()
{
SkuPriceListField.PriceSale,
SkuPriceListField.CostPurchase
}
};
var requestUri = new Uri(new Uri(serviceUrl), "product/ImportSkuPriceLists");
var myRequest = new MyRequest<SkuPriceListHeader, SkuPriceList>(priceListHeader, GetPriceLists());
return RestHelper.SendStreamedData<JobDto, SkuPriceListHeader, SkuPriceList>(
requestUri.AbsoluteUri, applicationId, secretKey, myRequest);
}
private static IEnumerable<SkuPriceList> GetPriceLists()
{
return new List<SkuPriceList>
{
new SkuPriceList
{
PartNo = "PartNo123", // Required key
PriceListCode = "PriceList1", // Required key
QuantityBreak = 1, // Required key
PriceSale = 2.00M, // Excl. VAT
CostPurchase = 1.00M // Excl. VAT
}
};
}