Close

Suggestion - Random products

shayt
11 years ago
#2242 Quote
Avatar
  • 46
Hi,

i would like to suggest a way to show RANDOM products,
the only problem in my way i will show below, that i did it for all the carousels, and i did some hard-coded values
so maybe you could implement it in a more correct way.

i added ALL my products to home page feature products,
and in the JCarousel.cshtml i did the following changes -

the code is too long, so i will just show the specific line i changed -
@if (Model.Items.Count > 0)
{
    var RandItemsCount = 10;
    var RandItems = Model.Items.OrderBy(x => Guid.NewGuid()).Take(RandItemsCount);  
    
    var skin = Model.Settings.Skin;


jQuery('#@carouselHtmlElementId').jcarousel({
                vertical: @Model.Settings.CarouselOrientation.ToString(CultureInfo.InvariantCulture).ToLower(),
                rtl: @supportRtl.ToString(CultureInfo.InvariantCulture).ToLower(),
                start: @Model.Settings.StartIndex,
                scroll: @Model.Settings.ScrollItems,
                animation: @Html.Raw(animationSpeed),
                auto: @Model.Settings.Autoscroll,
                size: @RandItemsCount @*@Model.Items.Count*@


<ul id="@carouselHtmlElementId" class="jcarousel-skin-@skin">
                @foreach (var item in RandItems @*Model.Items*@)
                {  


var jCarouselItemWidth = jQuery(jCarouselItem).css('width');
                    jCarouselItemWidth = jCarouselItemWidth.substring(0, jCarouselItemWidth.length - 2);

                    var itemsInTheCarousel = @RandItemsCount @*@Model.Items.Count*@;

                    var totalWidthOfAllItems = jCarouselItemWidth * itemsInTheCarousel;

                    



i hope you will implement it,
so i could define if i want a carousel with random or not,
and i hard coded 10 products, so please do it dynamically.

Thanks,
Shay
Boyko
11 years ago
#2243 Quote
Avatar
  • 1570
shayt wrote:
Hi,

i would like to suggest a way to show RANDOM products ...
Thanks,
Shay


Hi Shay,

Thank you for your suggestion!
Please feel free to add your idea in our UserVoice portal and let others vote for it.

Thanks
Regards,
Nop-Templates.com Team
shayt
11 years ago
#2337 Quote
Avatar
  • 46
the only problem right now,
that i need to give the carousel ALL the products, and only then i choose 10 random

so i think the performance might be damaged
because i needed to define 9999 in "Maximum number of items".

Shay