lpln
  •  lpln
  • 55.5% (Neutral)
  • Newbie Topic Starter
2017-09-11T13:31:57Z
hi
i wanna custom this module . i wanna to show product image with name , could you please help me how i can do.
Will Strohl
2017-09-23T02:03:00Z
Hello:

The default template for this view looks something like this:

<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.

@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>

Will Strohl, Upendo Ventures
Hotcakes Cloud  | Get Support  | Code Support 
Official Cloud & Support provider for Hotcakes
lpln
  •  lpln
  • 55.5% (Neutral)
  • Newbie Topic Starter
2017-09-27T15:36:12Z
hi dear
thancks so much for reply
i used these codes but images doesnt show yet.please see this this site :
http://mytest.com.iis2001.shared-servers.com/ 
Will Strohl
2017-09-30T18:01:51Z
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:

return product.ImageFileMedium;

Try replacing it with this:


return DiskStorage.ProductImageUrlSmall(
				hccApp,
				product.Bvin,
				product.ImageFileSmall,
				hccApp.IsCurrentRequestSecure());

Or this:


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:


@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 
Will Strohl, Upendo Ventures
Hotcakes Cloud  | Get Support  | Code Support 
Official Cloud & Support provider for Hotcakes
lpln
  •  lpln
  • 55.5% (Neutral)
  • Newbie Topic Starter
2017-10-03T13:52:44Z
thanks so much , now its ok.
Will Strohl
2017-10-03T17:17:53Z
Originally Posted by: lpln 

thanks so much , now its ok.



We're happy to help!
Will Strohl, Upendo Ventures
Hotcakes Cloud  | Get Support  | Code Support 
Official Cloud & Support provider for Hotcakes
DhruvishaLad
2018-12-12T11:20:08Z
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.
Will Strohl
2018-12-19T19:23:49Z
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! :)


Will Strohl, Upendo Ventures
Hotcakes Cloud  | Get Support  | Code Support 
Official Cloud & Support provider for Hotcakes
Loading
  • Sign-up for the Hotcakes Community Newsletter: