Contact me!
Eric Håård
+46 (0) 73 375 86 06

ImportSkuPriceList

C# example code for the ImportSkuPriceList method

Used to update pricing data for SKUs, keys are:

  • PartNo – SKU identifier
  • PriceListCode – Price list identifier
  • QuantityBreak – Usually 1, quantity break defines at which customer order value a certain price is active.

SKU and Price list must already exist in Storm Commerce, if not – data is ignored.

Example code:

static void Main()
{
    var serviceUrl = "https://stormstage.enferno.se/StormConnect/4.0/api/";
    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>()
        {
            // Creates/Updates only the below fields in the import.
            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()
{
    // NOTE Format and map your data to the StormConnect standard here
    return new List<SkuPriceList>
    {
        new SkuPriceList
        {
            PartNo = "PartNo123", // NOTE This is required key for pricelist
            PriceListCode = "PriceList1", // NOTE This is required key for pricelist
            QuantityBreak = 1, // NOTE This is a required key for pricelist
            PriceSale = 2.00M, // Excl VAT
            CostPurchase = 1.00M, // Excl VAT
        }
    };
}

Related:
Querying job status