Developer forum

Forum » Ecommerce - Standard features » Frontend products sorting like the same in Backend

Frontend products sorting like the same in Backend

Khine Lwin Myint
Reply

Hi,

I want to display the products like the sorting in the backend. I am using index option in the product catalogue. If there is any facet option, please advice me.

Backend sorting

Group 1

  • SubGroup A
    • Product ​a
    • Product c
    • Product g
  • SubGroup B
    • Product ​b
    • Product f
    • Product e

Group 2

  • SubGroup C
    • ​Product d
  • SubGroup D
    • Product ​h
    • Product g

I want to display them in the frontend like the followings.

  • ​Product a
  • Product c
  • Product g
  • Product ​b
  • Product f
  • Product e
  • Product d
  • ​Product h
  • Product g

I am using two options in the sorting like the attached image. But, I can't get what I want. Can someone give an advice for me if I am missing something?

Best Regards,

Khine

Sort.png

Replies

 
Morten Snedker Dynamicweb Employee
Morten Snedker
Reply

Hi Khine,

When you sort products in a groups, the order is saved to column GroupProductRelationSorting of table GroupProductRelation. So, your "Product a" will have sortorder value 1, and so will b/d/h - because they're the first product in each of their groups. So, any of the products a/b/d/h may appear first, selected by chance by SQL server.

So, you need to add a group sorting as well. You may do this by adding a group field with a number you wish to sort by. In an SQL world you would have a ORDER BY GroupOrder,GroupProductRelationSorting.

To make it more complicated, the column with the product sort order is not exposed as a sortable field when using the repository. So you would need to write (code) a schema extender that will include this column for your sorting. Upside is that you would be able to concatenate the sortorder of group/product into one sorting, ready for use by repository.

Bottom line is: you can't do it with standard functionality.

Best regards
Morten Snedker

 

 
Khine Lwin Myint
Reply

Hi Morten Snedker, 

Thank you so much for your reply.

Since the customer's products are not alot and customer do not mind use the backed sort feature in the ribbon.  May I know if this is a good way of doing it?   

Created a dummy group which is not clickable and not shown in menu, attached all products to this group and marked as primary  and then used "sort (primary group)". 

Is this a good solution?  If yes, may I know is there to default whenever a new product is created, auto attached to this dummy group and set as primary group?

Best Regards,

Khine

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply
This post has been marked as an answer

Hi Kihne,

 

If you do that, it will mess up canonicals and/or your ability to have proper breadcrumbs if the product belongs to multiple groups.

 

You can add a custom fields called "global sorting" and then sort by it instead.

 

Best Regards,

Nuno Aguiar

Votes for this answer: 1
 
Khine Lwin Myint
Reply

Hi Nuno Agular, 

Thanks. It works.

Best Regards,

Khine

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Glad I could help

 

You must be logged in to post in the forum