Empty category question

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
13 years ago
Is there a setting to show message in an empty category that items are on the way?

Steve
13 years ago
create the category and set it as published - write the text you want to appear


the category will appear in the category list and if the user clicks it, the text you wrote will appear - you don't need to have products in the category for this to work
7 years ago
haydie wrote:
create the category and set it as published - write the text you want to appear


the category will appear in the category list and if the user clicks it, the text you wrote will appear - you don't need to have products in the category for this to work


I think that is not what he asked, which I see was overlooked in development. When a category has zero products, there is no way to set a message. By default no message is shown when the recordset is empty.
7 years ago
Hello,

There is a way you can show some text on the category details page only if the category has no products.
You will need to modify the default nopCommerce code a bit, though.
In order to achieve that functionality you will have to edit the  ~/Presentation/Nop.Web/Views/Catalog/CategoryTemplate.ProductsInGridOrLines.cshtml file.

Choose where you want to add your text and add the following lines of code:

        @if (Model.Products.Count == 0)
        {
            <div>
        Your text here!
      </div>
        }

    
The model passed to the CategoryTemplate.ProductsInGridOrLines.cshtml is the CategoryModel. That model contains a List<Product> named Products. If the count of its members is equal to 0 the List is empty. That means that the category has no products.

Note: If you have the Include products from subcategories setting from Catalog Settings checked and you have products in the subcategories your text will not show.

Hope that helps!

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