Show New Products on Home Page

5 years ago
When trying to show Recently Added Products as a partial view in the home page (Index.chtml) I remove the layout code (ColumnsOne) from the view and add RecentlyAddedProducts to Index.cshtml yet the header loads into the page as well so that when you scroll to where New Products should be the nopcommerce logo appears. Has any body else encountered this, I'm not sure why. Maybe im missing something? I can not see why the layout continues to load.
5 years ago
If you are using the theme then you have to modified the theme RecentlyAddProduct views.

I think currently your views is loading from main Views\ directory not from your theme directory

Please make sure that you have updated the theme views and remove the layout from that views.
5 years ago
I'm not using a theme thanks anyway

I found a link somewhere in this forum about how to do it properly it involves a little more modification of the code.. I'll post the link when I find it again (answer posted September 2015)
4 years ago
Hi,

I have encountered the same issue in New product block in Index page. Header, footer and body also appears. Don't know what am i missing.

Kindly share some solution.


Thanks.
4 years ago
Hi,

to make it work you have to change the following line in the method which returns the view with new products:

return View(model);

to

return PartialView(model);
4 years ago
Jon.Hopley.Net wrote:
When trying to show Recently Added Products as a partial view in the home page (Index.chtml) I remove the layout code (ColumnsOne) from the view and add RecentlyAddedProducts to Index.cshtml yet the header loads into the page as well so that when you scroll to where New Products should be the nopcommerce logo appears. Has any body else encountered this, I'm not sure why. Maybe im missing something? I can not see why the layout continues to load.



Hi, This post can be useful for nopCommerce Community

We can show new products on Home page very easily, Need simple modify only view (cshtml file) part.

For this task at first open new product view file : ~/Themes/ThemeName/Views/Product/NewProducts.cshtml

Replace this code :

@model IList<ProductOverviewModel>
@{
    var controllerName = HttpContext.Current.Request.RequestContext.RouteData.Values["controller"].ToString();
    var actionName = HttpContext.Current.Request.RequestContext.RouteData.Values["action"].ToString();
    if (controllerName == "Home" && actionName == "Index")
    {
        Layout = "";
    }
    else
    {
        Layout = "~/Views/Shared/_ColumnsTwo.cshtml";
        //title
        Html.AddTitleParts(T("PageTitle.NewProducts").Text);
    }
}
    
@using Nop.Web.Models.Catalog;
<div class="page recently-added-products-page">
    <div class="page-title">
        <a href="@Url.RouteUrl("NewProductsRSS")" class="link-rss" title="@T("Products.NewProducts.RSS.Hint")">@T("Products.NewProducts.RSS")</a>
        <h1>@T("Products.NewProducts")</h1>
    </div>
    <div class="page-body">
        @if (Model.Count > 0)
        {
            <div class="product-grid">
                <div class="item-grid">
                    @foreach (var product in Model)
                    {
                        <div class="item-box">
                            @Html.Partial("_ProductBox", product)
                        </div>
                    }
                </div>
            </div>        
        }
    </div>
</div>






Then add (call) this action on Home page view file : ~/Themes/ThemeName/Views/Home/Index.cshtml

@Html.Action("NewProducts", "Product")



Note : I applied this Technic on nopCommerce 3.7 version
4 years ago
[email protected] wrote:
When trying to show Recently Added Products as a partial view in the home page (Index.chtml) I remove the layout code (ColumnsOne) from the view and add RecentlyAddedProducts to Index.cshtml yet the header loads into the page as well so that when you scroll to where New Products should be the nopcommerce logo appears. Has any body else encountered this, I'm not sure why. Maybe im missing something? I can not see why the layout continues to load.


Hi, This post can be useful for nopCommerce Community

We can show new products on Home page very easily, Need simple modify only view (cshtml file) part.

For this task at first open new product view file : ~/Themes/ThemeName/Views/Product/NewProducts.cshtml

Replace this code :

@model IList<ProductOverviewModel>
@{
    var controllerName = HttpContext.Current.Request.RequestContext.RouteData.Values["controller"].ToString();
    var actionName = HttpContext.Current.Request.RequestContext.RouteData.Values["action"].ToString();
    if (controllerName == "Home" && actionName == "Index")
    {
        Layout = "";
    }
    else
    {
        Layout = "~/Views/Shared/_ColumnsTwo.cshtml";
        //title
        Html.AddTitleParts(T("PageTitle.NewProducts").Text);
    }
}
    
@using Nop.Web.Models.Catalog;
<div class="page recently-added-products-page">
    <div class="page-title">
        <a href="@Url.RouteUrl("NewProductsRSS")" class="link-rss" title="@T("Products.NewProducts.RSS.Hint")">@T("Products.NewProducts.RSS")</a>
        <h1>@T("Products.NewProducts")</h1>
    </div>
    <div class="page-body">
        @if (Model.Count > 0)
        {
            <div class="product-grid">
                <div class="item-grid">
                    @foreach (var product in Model)
                    {
                        <div class="item-box">
                            @Html.Partial("_ProductBox", product)
                        </div>
                    }
                </div>
            </div>        
        }
    </div>
</div>






Then add (call) this action on Home page view file : ~/Themes/ThemeName/Views/Home/Index.cshtml

@Html.Action("NewProducts", "Product")



Note : I applied this Technic on nopCommerce 3.7 version


i use this in 3.8 but i am getting compilation error like "The type or namespace name 'productoverviewmodel' could not be found (are you missing a using directive or an assembly reference?)" how to fix this error ?
4 years ago
Please have a try with our free plugin for that.

Hope this help :)
4 years ago
[email protected] wrote:
...


looks like it should work well in 3.80. Make sure that you edited the correct view: Nop.Web\Views\Product\NewProducts.cshtml
or
Nop.Web\Themes\ThemeName\Views\Product\NewProducts.cshtml
4 years ago
Mariann wrote:
...

looks like it should work well in 3.80. Make sure that you edited the correct view: Nop.Web\Views\Product\NewProducts.cshtml
or
Nop.Web\Themes\ThemeName\Views\Product\NewProducts.cshtml




yes mamm for first time after change its work fine but after some time it shows this error..........