November Happy Hour will be moved to Thursday December 5th.

Price Update

Vote:
 

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.

#191766
Apr 27, 2018 13:11
Vote:
 

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);

#191767
Apr 27, 2018 13:17
Vote:
 

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.

#191769
Apr 27, 2018 13:43
Vote:
 

Can you post your entire code here?

#191770
Apr 27, 2018 13:48
Vote:
 

// 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);
dataTable.Rows.Add(row);

// 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);
cmd.ExecuteNonQuery();
}



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.

#191771
Edited, Apr 27, 2018 13:56
Vote:
 

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. 

#191772
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.