Close

JCarousel Random sorting ...

nicwinkri
10 years ago
#3127 Quote
Avatar
  • 1
Hi There

I have a JCarousel which uses "homepageFeaturedProducts" as datasource.

What I want to achive is getting the results random sorted. I found a general solution for this her:
http://www.nopcommerce.com/boards/t/12051/main-page-featured-products-question.aspx?p=2

the part
  @foreach (var item in Model.OrderBy(x => Guid.NewGuid()).Take(6))


seemed straight forward, but... in neoFashion theme the foreach loop is replaced with  

@(Html.DataList7Spikes<ProductOverviewModel>(Model, 4,
            @<div class="item-box">
                @Html.Partial("_ProductBox", item)
            </div>


How do I get to do a orderBy here?

Best Regards :-)
Nicolai
Boyko
10 years ago
#3136 Quote
Avatar
  • Moderator
  • 1570
Hi Nicolai,

Which version of the NeoFashion theme do you use?
Please note that we made the NeoFashion theme for nopCommerce 3.1 to be responsive and we have removed our helper and now we use a simple foreach statement.
But in any case the Model( which is a IList<ProductOverviewModel>) can be sorted just before the line where we use it. Something like this:

// sort the Model here just before passing it
@(Html.DataList7Spikes<ProductOverviewModel>(Model, 4,
            @<div class="item-box">
                @Html.Partial("_ProductBox", item)
            </div>



Please note that the JCarousel can't show the Featured products in an random order. You can make the same modification in the JCarousel view and presort the JCarousel items but this will affect all the carousels in your web site (all of them will display the items in a presorted order).
JCarousel view file is here:
Plugins\SevenSpikes.Nop.Plugins.JCarousel\Views\JCarousel\JCarousel.cshtml

Hope this information is useful!
Regards,
Nop-Templates.com Team