Try our conversational search powered by Generative AI!

Issue with storing sales price via Commerce api


Using: Commerce 1 R3a


I'am creating an import module to import a catalog in the Commerce, all works well except for the sales price.
The save function doesn't throw an error, but it also doesn't store the salesprice.

dto.HasChanges() is true
After storing the dto, the id of the priceRow id = -1
No exception but also no stored pricerow
SQL profiler shows Update Inventory, Varation and CatalogEntry but no update or insert of the sales price.
Decompiled code doesen't seem to store SalesPrice after calling the method SaveCatalogEntry.

So the big question, how do i store the sales price?

//Helper method of my import module
private static CatalogEntryDto.CatalogEntryRow SetVariation(Product product, MetaDataContext metaDataContext, IEnumerable<string> languageCodes, int catalogId, int metaClassId, CatalogEntryDto dto)
    var entryRow = dto.CatalogEntry.Count == 0
                                ? dto.CatalogEntry.NewCatalogEntryRow()
                                : dto.CatalogEntry[0];
    SetVariationEntryRow(product, entryRow, catalogId, metaClassId);
    if (entryRow.RowState == DataRowState.Detached)

    var inventoryRow = dto.Inventory.Count == 0
                           ? dto.Inventory.NewInventoryRow()
                           : dto.Inventory[0];
    SetInventoryRow(product, inventoryRow);
    if (inventoryRow.RowState == DataRowState.Detached) dto.Inventory.AddInventoryRow(inventoryRow);

    var variationRow = dto.Variation.Count == 0
                           ? dto.Variation.NewVariationRow()
                           : dto.Variation[0];
    SetVariationRow(product, variationRow, entryRow.CatalogEntryId);
    if (variationRow.RowState == DataRowState.Detached) dto.Variation.AddVariationRow(variationRow);

    var priceRow = dto.SalePrice.Count == 0
                           ? dto.SalePrice.NewSalePriceRow()
                           : dto.SalePrice[0];
    SetPriceRow(product, priceRow);
    if (priceRow.RowState == DataRowState.Detached) dto.SalePrice.AddSalePriceRow(priceRow);
    //All values are stored, except for the pricerow
    //Save Variation Entry

    SaveNodeRelation(product, catalogId, entryRow.CatalogEntryId);

    //Variation Meta data
    SetVariationMetaData(product, metaDataContext, languageCodes, entryRow.CatalogEntryId, metaClassId);

    return entryRow;

//Helper method of my import module
private static void SetPriceRow(Product product, CatalogEntryDto.SalePriceRow priceRow)
    if (product == null) throw new ArgumentNullException("product");
    if (priceRow == null) throw new ArgumentNullException("priceRow");

        priceRow.SaleCode = "";
        priceRow.Currency = "EUR";
        priceRow.ItemCode = product.Id.ToString(CultureInfo.InvariantCulture);
        priceRow.UnitPrice = product.Price;
        priceRow.MinQuantity = 0;
        priceRow.SaleType = 0;
        priceRow.StartDate = DateTime.Now.ToUniversalTime();
        priceRow.EndDate = DateTime.Now.AddYears(5).ToUniversalTime();
    catch (Exception ex)
        throw new ApplicationException(String.Format("Unable to set price row for product {0}.", product.Name), ex);

//Decompiled code of Mediachase library
internal void Save()
    if (this.CurrentDto.CatalogEntry == null)
    if (this.CurrentDto.CatalogEntry.Count == 0)
    DataCommand cmd = CatalogDataHelper.CreateDataCommand();
    using (TransactionScope transactionScope = new TransactionScope())
        DataHelper.SaveDataSetSimple(CatalogContext.MetaDataContext, cmd, this.CurrentDto, new string[]

May 17, 2013 9:51

Can you inspect sale price row in object "dto"? What is the status of the data row?

May 20, 2013 23:03

EPiServer Support solution (It worked for me):

Pricing has changed in R3 to use a pricing service instead (to better deal with markets). Try this code and see if it works better:

            CatalogEntryDto.CatalogEntryRow dtoRow = CatalogContext.Current.GetCatalogEntryDto([ENTRYCODE]).CatalogEntry.FirstOrDefault();
            CatalogKey ck = new CatalogKey(dtoRow);
            PriceValue ipv = new PriceValue();
            Currency currency = new Currency("SEK");

            ipv.CatalogKey = ck;
            ipv.CustomerPricing = CustomerPricing.AllCustomers;
            ipv.MarketId = MarketId.Default.Value;
            ipv.MinQuantity = 10;
            ipv.UnitPrice = new Money(101, currency);
            ipv.ValidFrom = DateTime.Now.AddDays(-1);
            ipv.ValidUntil = DateTime.Now.AddYears(1);

            List<PriceValue> list = new List<PriceValue>();

            IPriceService priceService = ServiceLocator.Current.GetInstance<IPriceService>();
            var p1 = priceService.GetCatalogEntryPrices(ck); // get all existing prices and add to the list
            priceService.SetCatalogEntryPrices(new CatalogKey(dtoRow), list); // if done like this all previous prices are gone

Edited, May 21, 2013 8:42

Try Mediachase.Commerce.Catalog.Managers.CatalogEntryManager.SaveCatalogEntry


May 21, 2013 15:26
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.