Category has no product message

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

If category has no product - how to display message as

"No Product "
4 years ago
You can achieve this by modifying the category razor view file:

/Views/Catalog/CategoryTemplate.ProductsInGridOrLines.cshtml (or corresponding theme file).


Locate where the products are populated - Here in v4.1 https://github.com/nopSolutions/nopCommerce/blob/release-4.10/src/Presentation/Nop.Web/Views/Catalog/CategoryTemplate.ProductsInGridOrLines.cshtml#L142

Add an else path to the if statement like this:


        @if (Model.Products.Count > 0)
        {
            <div class="@(Model.PagingFilteringContext.ViewMode == "list" ? "product-list" : "product-grid")">
                <div class="item-grid">
                    @foreach (var product in Model.Products)
                    {
                        <div class="item-box">
                            @await Html.PartialAsync("_ProductBox", product)
                        </div>
                    }
                </div>
            </div>
        }
        else
        {
            <div>No Product</div>
        }


Or if you want it localized:


<div>@T("Custom.NoProducts")</div>



And add Custom.NoProducts to the string resources.
4 years ago
Thanks
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.