I have a brief question, it is probably a simple thing to do but I really need a little guidance about it.
I have a list of products in Merchello on an umbraco-based website.
The customer wants to know how many days each product takes in the inventory. Or in other words since a product was added to "merchello" until today, how many days have passed?
I have tried to do it in theory there are two properties UpdateDate and CreateDate but when inspecting the element. Both dates are the same.
But using the product key and reviewing the database in the "merchProduct" table, these dates really are different and can be used for the required purpose.
Some help on how to get that data "Days on Inventory".
Beforehand, thanks for any help.
Thanks to you Martin Aguirre i found the solution.... And here's is my custom code to get the correct Product Create Date...
/* This is a direct query to the database to get real product create date*/
var Database = ApplicationContext.Current.DatabaseContext.Database;
var sqlSyntax = ApplicationContext.Current.DatabaseContext.SqlSyntax;
//Create a poco Object
@functions{
[TableName("merchProduct")]
private class merchProduct
{
[Column("pk")]
public Guid pk { get; set; }
[Column("updateDate")]
public DateTime updateDate { get; set; }
[Column("createDate")]
public DateTime createDate { get; set; }
}
}
//Make the query
var sql = new Sql();
sql.Select("*")
.From<merchProduct>(sqlSyntax)
.Append("WHERE pk = '" + Model.Key + "'");
var productDates = Database.Fetch<merchProduct>(sql).FirstOrDefault();
//You can change System.DateTime.Now for any other date of your convenience
DateTime createDate = (productDates != null) ? productDates.createDate : System.DateTime.Now;
//Calculate how many days has this product on the inventory
double daysOnInventory = Math.Round((DateTime.Now - createDate).TotalDays);
//Print daysOnInventory
<div class="text-muted text-center">Days On Inventory: @daysOnInventory</div>
This worked for me... I hope that can be usefull for some one else...
Merchello Inventory Product CreateDate
Hi everyone.
I have a brief question, it is probably a simple thing to do but I really need a little guidance about it.
I have a list of products in Merchello on an umbraco-based website. The customer wants to know how many days each product takes in the inventory. Or in other words since a product was added to "merchello" until today, how many days have passed?
I have tried to do it in theory there are two properties UpdateDate and CreateDate but when inspecting the element. Both dates are the same.
But using the product key and reviewing the database in the "merchProduct" table, these dates really are different and can be used for the required purpose.
Some help on how to get that data "Days on Inventory". Beforehand, thanks for any help.
Hi.
Maybe these dates are the dates of the model. check inside de PK element to verify if exist another properties.
then use this
https://msdn.microsoft.com/es-ar/library/cc437579(v=vs.71).aspx
to get the days between dates.
Update!!! check these previous response
https://our.umbraco.org/projects/collaboration/merchello/merchello/76967-programmatically-retrieve-products-collection
Hi... Sorry for my late response...
Thanks to you
Martin Aguirre
i found the solution.... And here's is my custom code to get the correct Product Create Date...This worked for me... I hope that can be usefull for some one else...
Regards
is working on a reply...