Price Update


Hi All,

Is there any way to update the price in Variant through Stored procedure? It seems, There is no Update method Explicitly. So I trying to Delete the existing Entries ( Delete(IEnumerable  PriceValueIds ). And save the new price entry. 
But not able to delete the Existing Price Entries using Stored Procedure. 
Please help me out.

Thanks in Advance.

Apr 27, 2018 13:11

It depends on what you want to do. If you want to update the entire prices of a SKU, you can use IPriceService.SetCatalogEntryPrices(CatalogKey catalogKey, IEnumerable<IPriceValue> priceValues); The prices which are not in priceValues will be deleted.

If you want to update a specific price, or prices, then use IPriceDetailService.Save(IEnumerable<IPriceDetailValue> priceValues);

Apr 27, 2018 13:17

Thanks Quan..

My need is, just update the price. i did the same (  IPriceDetailService.Save(IEnumerable<IPriceDetailValue>  ). But, its duplicated the one more row. not updated the price in existing Row Quan.

Apr 27, 2018 13:43

Can you post your entire code here?

Apr 27, 2018 13:48

// Price Detail Table
var row = dataTable.NewRow();
row["ApplicationId"] = GlobalSettings.ApplicationID;
row["CatalogEntryCode"] = "P-23453";
row["MarketId"] = "DEFAULT";
row["CurrencyCode"] = "USD";
row["PriceTypeId"] = 1;
row["PriceCode"] = "Customer";
row["ValidFrom"] = DateTime.UtcNow;
row["MinQuantity"] = 0;
row["UnitPrice"] = Convert.ToDecimal(290);

// catalog Entry
DataTable catalogEntryTable = new DataTable();
catalogEntryTable.Columns.Add("ApplicationId", typeof(Guid));
catalogEntryTable.Columns.Add("CatalogEntryCode", typeof(string));
var row = catalogEntryTable.NewRow();
row["ApplicationId"] = GlobalSettings.ApplicationID;
row["CatalogEntryCode"] = "P-23453";

// SP for save the price
using (SqlCommand cmd = new SqlCommand("ecf_PriceDetail_ReplacePrices", connection))
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@CatalogKeys", catalogEntryTable);
cmd.Parameters.AddWithValue("@PriceValues", dataTable);

Above code is working fine when i set the price for first time.But , If i  udpate the price second time, one more row added, instead of update the price in Existing row. Thats my problem.

Edited, Apr 27, 2018 13:56

It is entirely different from  IPriceDetailService.Save(IEnumerable<IPriceDetailValue>. If you want to update a price, you need to load it first and update its values, then save it back. 

Apr 27, 2018 13:58
* 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.