Show New Products on Home Page

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
8 年 前
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.
8 年 前
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.
8 年 前
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)
7 年 前
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.
7 年 前
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);
7 年 前
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
7 年 前
[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 ?
7 年 前
Please have a try with our free plugin for that.

Hope this help :)
7 年 前
[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
7 年 前
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..........
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.