Category sorting alpahabetical

3 years ago
HI there everybody,
We are trialing v3.8. We have a lot of categories and subcategories.
We sell printers so the parnet category is the printer make i.e. Samsung and the child category the model number of which there may be hundreds to choose from i.e Samsung : ML 12000
is there any setting to enable the parent categories and most importantly the child sub categories to display in an alphabetical order?
otherwise its very hard to navigate...
Thanks!!!
3 years ago
toadman wrote:

is there any setting to enable the parent categories and most importantly the child sub categories to display in an alphabetical order?


As per my knowledge, there is no default setting.  
There are several possible way to do so!

First, you can use Display Order to sort sub-category, but if you have numbers of category then it would be hard.

Second way, Change the code on CategoryTemplate.ProductsInGridOrLines.cshtml


<div class="category-grid sub-category-grid">
  <div class="item-grid">
     @foreach (var item in Model.SubCategories)
     {...

To

<div class="category-grid sub-category-grid">
    <div class="item-grid">
       @foreach (var item in Model.SubCategories.OrderBy(subcat=>subcat.Name))
        {...  


Side notes: There will be another possible ways also!
3 years ago
toadman wrote:
HI there everybody,
We are trialing v3.8. We have a lot of categories and subcategories.
We sell printers so the parnet category is the printer make i.e. Samsung and the child category the model number of which there may be hundreds to choose from i.e Samsung : ML 12000
is there any setting to enable the parent categories and most importantly the child sub categories to display in an alphabetical order?
otherwise its very hard to navigate...
Thanks!!!

It is entirely possible using the Sort Order for each of your categories. You just have to adjust the "sub" categories sort order so that it is alphabetical.

In other words, like this:

If one subcategory is named "Accent" and another is named "Accellerate", you will want to set the sort order of "Accelerate" to be #1 and the sort order for "Accent" to #2...etc...


Aprons #1
Astronaut Helmets #2
Baseball Bats #3
3 years ago
Hi there
Thanks for the replies. in which folder can I find the file: CategoryTemplate.ProductsInGridOrLines.cshtml
3 years ago
toadman wrote:
Hi there
Thanks for the replies. in which folder can I find the file: CategoryTemplate.ProductsInGridOrLines.cshtml


You can find it at: Presentation > Nop.Web > Views > Catalog > CategoryTemplate.ProductsInGridOrLines.cshtml
3 years ago
Thank you
2 years ago
Hi,

I've change the code like proposed:


<div class="category-grid sub-category-grid">
    <div class="item-grid">
       @foreach (var item in Model.SubCategories.OrderBy(subcat=>subcat.Name))
        {...  

I have started the shop again and cleared the chache of the browser. But it shows no effect.

What could be the cause?

regards

Torsten