Donald Johansson
2018-07-15T23:11:16Z
Which module do I use to display the most recently added products to my store? I don't see any option for it in any module,. but I might be looking in the wrong place.
I haven't really looked much into the details of the content column and block functionality. Is that what I need to use?

Thank you,
Donald ๐Ÿ™‚
Will Strohl
2018-07-20T15:41:50Z
There isn't a built-in view that displays products based on the date the product was added to the store. This is possible to do though.


  1. If you're not already doing so, create your custom viewset.
  2. Add a new view in the Category viewset folder and name it something like, "NewestFirst.cshtml"
  3. Use LINQ to change the sort at this line of code: foreach (var item in Model.Products)
  4. Save the view
  5. Apply the view at the module or category-level

Will Strohl, Upendo Ventures
Hotcakes Cloud  | Get Support  | Code Support 
Official Cloud & Support provider for Hotcakes
Donald Johansson
2018-07-24T13:38:34Z
Thank you Will!

I have been doing some changes to the viewsets, but am having some problems with this one.

I changed line 32 in the category viewset to this:
@foreach (var item in Model.Products.OrderBy(CreationDate))

But am getting this error:
"error CS0103: The name 'CreationDate' does not exist in the current context at System.Web.Compilation.AssemblyBuilder.Compile()"

I checked the database, and I see the 'CreationDate' column in the products table, so I assume that's what I need to use?

The problem is probably my limited knowledge of LINQ. I tried something like this, but without any better results.

@foreach (var item in Model.Products.OrderBy(CreationDate =>CreationDate))

Thanks!
Reto Cossalter
2018-07-25T08:30:39Z
Try using the following notation:

@foreach (var item in Model.Products.OrderBy(i => i.CreationDate))
Will Strohl
2018-08-13T17:16:09Z
^^^ What Reto said. ๐Ÿ™‚
Will Strohl, Upendo Ventures
Hotcakes Cloud  | Get Support  | Code Support 
Official Cloud & Support provider for Hotcakes
Will Strohl
2018-08-13T17:23:56Z
https://github.com/Hotca...Commerce/core/issues/151 
Will Strohl, Upendo Ventures
Hotcakes Cloud  | Get Support  | Code Support 
Official Cloud & Support provider for Hotcakes
Donald Johansson
2018-08-15T16:11:34Z
Thank you both for the replies!
I am sure that is the correct LINQ syntax, but I am still getting an error. My guess is that the variable is actually not part of the call to the database?

This is the error I am seeing:

'Hotcakes.Modules.Core.Models.SingleProductViewModel' does not contain a definition for 'CreationDate' and no extension method 'CreationDate' accepting a first argument of type 'Hotcakes.Modules.Core.Models.SingleProductViewModel' could be found
Reto Cossalter
2018-08-16T09:43:30Z
You are right, SingleProductViewModel does not contain this property. Sorry, my bad.
But you could try to access the Product via Item { get; set; } that is type of Product

@foreach (var item in Model.Products.OrderBy(i => i.Item.CreationDateUtc))

or maybe the LastUpdated

@foreach (var item in Model.Products.OrderBy(i => i.Item.LastUpdated))

Loading
  • Sign-up for the Hotcakes Community Newsletter: