Category images on category page

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
5 years ago
Hi,

I'm currently building a nopCommerce site using v4.0, all going well, but have come across a small issue I can't figure out. When setting up my product categories you are able to add a separate category image for each one, I expected this to be viewed at the top of the category product listing page, but nothing shows, is there some setting I am missing somewhere to be able to show the category image?

Any help would be much appreciated.

Many thanks

Nick
5 years ago
Hi,
Is category listing on top of the category page?

On category page, at top of the page only child category will display. Make sure you configured child catgegory on your nopCommerce store.
5 years ago
Hi Raju,

Thanks for getting back to me, I want to display the parent category image, as the sub categories are displayed as links, see screenshot https://ibb.co/dd25re, do you know how I can display the parent image?

Many thanks again

Nick
5 years ago
Hi Nick,

You can develop widget plugin and display category picture on widget.
5 years ago
You can add below code snippet in -> Views\Catalog\CategoryTemplate.ProductsInGridOrLines.cshtml
(if you are using theme than add at -> \Themes\<THEME_FOLDER>\Views\Catalog\CategoryTemplate.ProductsInGridOrLines.cshtml) view page whenever you want display current category picture.


  @{ 
            string categoryPictureURL = "";
            var _pictureService = EngineContext.Current.Resolve<Nop.Services.Media.IPictureService>();
            var category = EngineContext.Current.Resolve<Nop.Services.Catalog.ICategoryService>().GetCategoryById(Model.Id);
            categoryPictureURL = _pictureService.GetPictureUrl(_pictureService.GetPictureById(category.PictureId));

        }
        <img src="@categoryPictureURL" alt="@Model.Name"/>


If you want to add it before sub-category listing, than add it after  
@Html.Widget("categorydetails_before_subcategories", Model.Id)
line and before comment  
@*subcategories*@
line

check this screen shot. This will help you.
5 years ago
Many thanks Raju,

Your solution worked perfectly, I just needed to add the @using Nop.Core.Infrastructure; at the top of the page for it to work.

Have a great day

Cheers

Nick
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.