Rank: Newbie
Groups: Registered, Registered Users, Subscribers Joined: 12/28/2016(UTC) Posts: 7
Thanks: 2 times
|
hi i wanna custom this module . i wanna to show product image with name , could you please help me how i can do.
|
|
|
|
Rank: Administration
Groups: Administrators, HCC-Employee-Store-Manager, HCC-Employee-Support, HCC-Partner, Moderators, Partners, Registered, Registered Users, Subscribers Joined: 12/22/2016(UTC) Posts: 341  Thanks: 77 times Was thanked: 59 time(s) in 57 post(s)
|
Hello: The default template for this view looks something like this: Code:<div class="hc-top-10-products">
<h2>@Model.Title</h2>
<ol>
@foreach (var item in Model.Items)
{
<li><a href="@item.Url" title="@item.Title">@item.Name</a></li>
}
</ol>
</div>
The product name already appears to be there. It sounds like you want to show an image along with the name. Here's a snippet replacement that can help you get there. It's untested, but it should get you where you need to be. Note the additional method, and the image added to the HTML. Code:@model Hotcakes.Modules.Core.Models.SideMenuViewModel
@functions{
string GetProductImage(string url)
{
// get an instance of the Hotcakes application
var hccApp = Hotcakes.Commerce.HotcakesApplication.Current;
// create a cache key
var current = DotNetNuke.Entities.Portals.PortalController.Instance.GetCurrentPortalSettings();
var cacheKey = string.Concat("HccTop10", current.ActiveTab);
// see if the products are already cached
var cachedItems = DotNetNuke.Services.Cache.CachingProvider.Instance().GetItem(cacheKey);
if (cachedItems == null)
{
// load the products from a query only if a cached collection doesn't already exist
var s = new DateTime(1900, 1, 1);
var e = new DateTime(3000, 12, 31);
cachedItems = hccApp.ReportingTopSellersByDate(s, e, 10);
// cache the products to prevent performance issues
DotNetNuke.Services.Cache.CachingProvider.Instance().Insert(cacheKey, cachedItems);
}
// convet the cached products to a usable list
var products = (List<Hotcakes.Commerce.Catalog.Product>) cachedItems;
// iterate through each of the 10 products in the collection
foreach (var product in products)
{
if (Hotcakes.Commerce.Utilities.UrlRewriter.BuildUrlForProduct(product) == url)
{
// return the product image only if the URL's match
return product.ImageFileMedium;
}
}
// return a generic image, in the event that there isn't a matching product image/URL
return "/Portals/0/some-folder/generic-image.png";
}
}
<div class="hc-top-10-products">
<h2>@Model.Title</h2>
<ol>
@foreach (var item in Model.Items)
{
<li><a href="@item.Url" title="@item.Title">
<img src="@GetProductImage(item.Url)" alt=""/><br />@item.Name
</a></li>
}
</ol>
</div>
|
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users, Subscribers Joined: 12/28/2016(UTC) Posts: 7
Thanks: 2 times
|
|
|
|
|
Rank: Administration
Groups: Administrators, HCC-Employee-Store-Manager, HCC-Employee-Support, HCC-Partner, Moderators, Partners, Registered, Registered Users, Subscribers Joined: 12/22/2016(UTC) Posts: 341  Thanks: 77 times Was thanked: 59 time(s) in 57 post(s)
|
It actually looks like it is working, but the image path isn't complete. It's only the image file name, and it doesn't include the rest of the image path. (Like I said, it was untested.) Look for this line of code in the example: Code:return product.ImageFileMedium;
Try replacing it with this: Code:
return DiskStorage.ProductImageUrlSmall(
hccApp,
product.Bvin,
product.ImageFileSmall,
hccApp.IsCurrentRequestSecure());
Or this: Code:
return DiskStorage.ProductImageUrlOriginal(
hccApp,
product.Bvin,
product.ImageFileSmall,
hccApp.CurrentRequestContext.RoutingContext.HttpContext.Request.IsSecureConnection);
You'll probably also need to import one or both of the following namespaces: Code:
@using Hotcakes.Commerce.Storage
@using Hotcakes.Commerce.Utilities
By the way, this kind of inquiry is covered, with guaranteed response times under our Developer Support Services. https://upendoventures.c...mmerce-Developer-Support |
|
 1 user thanked Will Strohl for this useful post.
|
|
|
Rank: Newbie
Groups: Registered, Registered Users, Subscribers Joined: 12/28/2016(UTC) Posts: 7
Thanks: 2 times
|
thanks so much , now its ok.
|
|
|
|
Rank: Administration
Groups: Administrators, HCC-Employee-Store-Manager, HCC-Employee-Support, HCC-Partner, Moderators, Partners, Registered, Registered Users, Subscribers Joined: 12/22/2016(UTC) Posts: 341  Thanks: 77 times Was thanked: 59 time(s) in 57 post(s)
|
Originally Posted by: lpln  thanks so much , now its ok. We're happy to help! |
|
|
|
|
Rank: Newbie
Groups: Registered, Unverified Users Joined: 12/12/2018(UTC) Posts: 1
|
hi i wanna custom this module . i wanna to show product image with name & short Description, too. could you please help me how i can do.
|
|
|
|
Rank: Administration
Groups: Administrators, HCC-Employee-Store-Manager, HCC-Employee-Support, HCC-Partner, Moderators, Partners, Registered, Registered Users, Subscribers Joined: 12/22/2016(UTC) Posts: 341  Thanks: 77 times Was thanked: 59 time(s) in 57 post(s)
|
Originally Posted by: DhruvishaLad  hi i wanna custom this module . i wanna to show product image with name & short Description, too. could you please help me how i can do. Could you please post a new thread in the forum asking this question? Also, it would be super helpful if you could include more details about what you're trying to do. Thanks! :) |
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.