Orderby noderelation sortorder



Is it possible to get results (products) ordered by a specific noderelation sort order?

extra question that might solve alot ... are NodeEntryRelations mapped to find? 

Edited, Jul 09, 2019 13:55


I've actually had to do something similar before, and I found it quite tough to be honest - more for the fact that products can exist in multiple nodes in the catalog, so you will need to index the order of the product in those nodes. 

When I did I used the RelationRepository to get the node relations for a given product - when you get a relation, with that you can read the sort order of the given product in that node. 

Because the product was found in multiple nodes, I stored the sort orders in a dictionary, with a key of the node ID. 

Then when it comes to ordering via Find, you can order by the value of a dictionary item - so something like this:

search.OrderBy(x => x.SortOrder[catalogNode.ID]);

The major headache with this is when the sort order is changed - if you were to move one particular product in a particular node this would cause the sort order of the other items in that node to change aswell, and they would need to be reindexed - I tried to handle this by reindexing on events fired based on the sorting of the products, but this came with some performance issues, and locking of the UI, so in the end we trained editors to reindex the products manually in the event of the sort order being changed - alternatively if you reindex frequently this would obviously take care of this aswell. 

Hope this helps!


Edited, Jul 09, 2019 15:07
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.