I had written an ActionResult and a corrsponding view to display a book of the day in the right column in v2.4
What it simply does is that I just pass the product Id to bookOfTheDay in the All Setting in Admin panel and it would get that product and display it.
[ChildActionOnly]
public ActionResult BookOfTheDayBlock()
{
var model = new List<ProductModel>();
var product = _productService.GetProductById(_catalogSettings.bookOfTheDay);
model.Add(PrepareProductOverviewModel(product, true, true));
return PartialView(model);
}
@model IList<Nop.Web.Models.Catalog.ProductModel>
@using Nop.Core;
@using Nop.Core.Infrastructure;
@using Nop.Web.Framework.UI;
@using Nop.Web.Models.Catalog;
@if (Model.Count > 0)
{
<div class="block block-recently-viewed-products">
<div class="title">
Book of the day
</div>
<div class="clear">
</div>
<div class="listbox">
@for (int i = 0; i < Model.Count; i++)
{
var product = Model[i];
<a href="@Url.RouteUrl("Product", new { productId = product.Id, SeName = product.SeName })">@product.Name</a>
<div class="poll-take-poll">
<div class="picture" style="text-align:center;">
<a href="@Url.RouteUrl("Product", new { productId = product.Id, SeName = product.SeName })" title="@product.DefaultPictureModel.Title">
<img style="border-width: 0px; float:none" alt="@product.DefaultPictureModel.AlternateText" src="@product.DefaultPictureModel.ImageUrl" title="@product.DefaultPictureModel.Title" />
</a>
</div>
@Html.Raw(product.ShortDescription)
<br />
<div class="title" style="background:none; text-align:center;">
Only for @Html.Raw(product.ProductPrice.Price)
</div>
</div>
}
</div>
</div>
}
When I ported the same code to v2.6 it did not find the method "PrepareProductOverviewModel" in the line
model.Add(PrepareProductOverviewModel(product, true, true));
Instead there is a function "PrepareProductOverviewModels" which I tried to use but it requires the "product" to be of the type Generic.IEnumerable which I dont know how to get. Any help would be appreciated.
Thank you.
P.S. Also if someone can also quickly go through the view and point out any programming or performance issues as I have copied and pasted code from multiple places. It works fine though there are no issues in it.