home page also show new products

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
4 years ago
I'm using version 4.20. Products marked as new. How do I show your homepage? Can you help me.
4 years ago
Can you please clear a little about "How do I show your homepage?". If you want to show the product at homepage then check the "show on home page" from the admin panel.
4 years ago
If your query is about displaying new products on the homepage then you can take a look at this thread. The thread gives you an insight into the implementation but it is targeting an older version of NopCommerce. You can achieve the result in 4.2 by making use of ViewComponent instead of Html.Action() or you can develop a widget plugin and display the new products on the homepage.
4 years ago
sina.islam wrote:
Can you please clear a little about "How do I show your homepage?". If you want to show the product at homepage then check the "show on home page" from the admin panel.


I know that trait. My question is this. I want to show the new products on the main page.
4 years ago
sanju.dahal741 wrote:
If your query is about displaying new products on the homepage then you can take a look at this thread. The thread gives you an insight into the implementation but it is targeting an older version of NopCommerce. You can achieve the result in 4.2 by making use of ViewComponent instead of Html.Action() or you can develop a widget plugin and display the new products on the homepage.


I understand. thank you for your concern. I am a novice. Can you help me with how ? Please.
4 years ago
You may directly render a new view component from the Nop.Web/Views/Home/Index.cshtml page as:
@await Component.InvokeAsync("HomePageNewProducts")


Create a class named "HomePageNewProducts" and inherit the abstract class "NopViewComponent". Create a method named invoke() which return "IViewComponentResult" and pull the new products from product service.
SearchProducts(storeId: _storeContext.CurrentStore.Id,
                visibleIndividuallyOnly: true,
                markedAsNewOnly: true,
                orderBy: ProductSortingEnum.[orderby],
                pageSize: numberofProducts);

Convert the product into appropriate view model and return an appropriate view from the invoke() method. You can refer to the NewProduct() method of Product controller and its view NewProducts.cshtml.

If you want to use a plugin then it can be achieved via a widget plugin. I have written a brief summary of the widget plugin here. You can follow the approach to create the widget plugin. For the widget zones, you could select any of the widget zone available on the homepage like "PublicWidgetZones.HomepageTop" or "PublicWidgetZones.HomepageBeforeBestSellers" or "PublicWidgetZones.HomepageBeforePoll" or any other widget zone available in the Nop.Web/Views/Home/Index.cshtml.
In your Plugin's view component's invoke method, you can follow the same mechanism mentioned above.
4 years ago
sanju.dahal741 wrote:
You may directly render a new view component from the Nop.Web/Views/Home/Index.cshtml page as:
@await Component.InvokeAsync("HomePageNewProducts")


Create a class named "HomePageNewProducts" and inherit the abstract class "NopViewComponent". Create a method named invoke() which return "IViewComponentResult" and pull the new products from product service.
SearchProducts(storeId: _storeContext.CurrentStore.Id,
                visibleIndividuallyOnly: true,
                markedAsNewOnly: true,
                orderBy: ProductSortingEnum.[orderby],
                pageSize: numberofProducts);

Convert the product into appropriate view model and return an appropriate view from the invoke() method. You can refer to the NewProduct() method of Product controller and its view NewProducts.cshtml.

If you want to use a plugin then it can be achieved via a widget plugin. I have written a brief summary of the widget plugin . You can follow the approach to create the widget plugin. For the widget zones, you could select any of the widget zone available on the homepage like "PublicWidgetZones.HomepageTop" or "PublicWidgetZones.HomepageBeforeBestSellers" or "PublicWidgetZones.HomepageBeforePoll" or any other widget zone available in the Nop.Web/Views/Home/Index.cshtml.
In your Plugin's view component's invoke method, you can follow the same mechanism mentioned above.


Thank You.
4 years ago
Link for the brief summary of the widget zone
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.