Main Page - Featured products question

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 years ago
I would like to limit the number of featured products displayed on the Home Page to X.   I would like the pictures to be randomly selected from ALL products enabled as a featured product.  ie. set 12 products as featured, and then limit the featured products on the Home Page to 6.  Each time the page loads, it selects 6 random images from the 12 set as featured.

Does anything like this exist?  Would it be hard to do?
12 years ago
markw78 wrote:
I would like to limit the number of featured products displayed on the Home Page to X.   I would like the pictures to be randomly selected from ALL products enabled as a featured product.  ie. set 12 products as featured, and then limit the featured products on the Home Page to 6.  Each time the page loads, it selects 6 random images from the 12 set as featured.

Does anything like this exist?  Would it be hard to do?

https://www.nopcommerce.com/boards/t/5393/random-featured-products-on-home-page.aspx
12 years ago
Spoke too soon...

What about 2.0?  Should have mentioned that in my post
12 years ago
For 2.10 and 2.20, change your HomepageProducts.cshtml view to the following (changes underlined):
@model HomePageProductsModel
@using Nop.Web.Framework.UI;
@using Nop.Web.Models.Catalog;
@if (Model.Products.Count > 0)
{
    <div class="product-grid home-page-product-grid">
        <div class="title">
            @T("HomePage.Products")
        </div>
        <div class="clear">
        </div>
        @{
            var products = Model.Products.OrderBy(x => Guid.NewGuid()).Take(6);
        }
        @if (Model.UseSmallProductBox)
        {
            @(Html.DataList<ProductModel>(products, 3,
            @<div class="item-box">
                @Html.Partial("_ProductSmallBox", @item)
            </div>
                ))
        }
        else
        {
        @(Html.DataList<ProductModel>(products, 2,
            @<div class="item-box">
                @Html.Partial("_ProductBox", @item)
            </div>
                ))
        }
    </div>
}
.
12 years ago
ugh, sorry... I should have been even MORE specific...  Didn't think this would be that different between 2.0 and 2.10

2.10... a few minor differences, model line, and lacking the if statements


@model IList<ProductModel>

@using Nop.Web.Framework.UI;
@using Nop.Web.Models.Catalog;
@if (Model.Count > 0)
{
    <div class="home-page-product-grid">
        <div class="title">
            @T("HomePage.Products")
        </div>
        <div class="clear">
        </div>
        @(Html.DataList<ProductModel>(Model, 3,
            @<div class="item-box">
                <div class="item">
                    <div class="product-title">
                        <a href="@Url.RouteUrl("Product", new { productId = item.Id, SeName = item.SeName })" title="@item.DefaultPictureModel.Title">
                            @item.Name</a>
                    </div>
                    <div class="picture">
                        <a href="@Url.RouteUrl("Product", new { productId = item.Id, SeName = item.SeName })" title="@item.DefaultPictureModel.Title">
                            <img style="border-width: 0px;" alt="@item.DefaultPictureModel.AlternateText" src="@item.DefaultPictureModel.ImageUrl"
                                        title="@item.DefaultPictureModel.Title" /></a>
                    </div>
                </div>
            </div>
            ))
    </div>
}
12 years ago
For 2.00, change your HomepageProducts.cshtml view to the following (change underlined, line 13):
@model IList<ProductModel>

@using Nop.Web.Framework.UI;
@using Nop.Web.Models.Catalog;
@if (Model.Count > 0)
{
    <div class="home-page-product-grid">
        <div class="title">
            @T("HomePage.Products")
        </div>
        <div class="clear">
        </div>
        @(Html.DataList<ProductModel>(Model.OrderBy(x => Guid.NewGuid()).Take(6), 3,
            @<div class="item-box">
                <div class="item">
                    <div class="product-title">
                        <a href="@Url.RouteUrl("Product", new { productId = item.Id, SeName = item.SeName })" title="@item.DefaultPictureModel.Title">
                            @item.Name</a>
                    </div>
                    <div class="picture">
                        <a href="@Url.RouteUrl("Product", new { productId = item.Id, SeName = item.SeName })" title="@item.DefaultPictureModel.Title">
                            <img style="border-width: 0px;" alt="@item.DefaultPictureModel.AlternateText" src="@item.DefaultPictureModel.ImageUrl"
                                        title="@item.DefaultPictureModel.Title" /></a>
                    </div>
                </div>
            </div>
            ))
    </div>
}
12 years ago
Sir,


I have installed Nop Commerce Store.... i had opened demo "Front End"


But I dont know to open "Admin Panel"

how to open d admin panel from Visual Studio 2010......


Please guide me
12 years ago
Thanks mb, that did it.

Amazingly easy if your familiar enough with the code I guess.   Thanks again!
12 years ago
Hi,


I am struggling with OrderBy, I wish to order the Products based on display order or any other product variant field on the home page.


I am using version 2.3.


Thanks in advance,
Avtar
11 years ago
This doesn't seem to work with 2.80.

Compiler Error Message: CS0246: The type or namespace name 'HomePageProductsModel' could not be found (are you missing a using directive or an assembly reference?)

Source Error:

Line 41:    
Line 42:    
Line 43:     public class _Page_Views_Catalog_HomepageProducts_cshtml : Nop.Web.Framework.ViewEngines.Razor.WebViewPage<HomePageProductsModel> {
Line 44:
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.