Search page 'Order by position'

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Hace 7 años
Hi on the 'search page' I get the same results 'order by position' as 'order by name: a-z' although each product has its own DisplayOrder different from an alphabetical sort. I don´t know if the search page order by position will use the dbo.Product/DisplayOrder criteria.

I appreciate any help.

Best regards.
Hace 7 años
mrrac wrote:
Hi on the 'search page' I get the same results 'order by position' as 'order by name: a-z' although each product has its own DisplayOrder different from an alphabetical sort. I don´t know if the search page order by position will use the dbo.Product/DisplayOrder criteria.

I appreciate any help.

Best regards.


If you see the flowing code then you may understand what's going on

==?

//sort products
                if (orderBy == ProductSortingEnum.Position && categoryIds != null && categoryIds.Any())
                {
                    //category position
                    var firstCategoryId = categoryIds[0];
                    query = query.OrderBy(p => p.ProductCategories.FirstOrDefault(pc => pc.CategoryId == firstCategoryId).DisplayOrder);
                }
                else if (orderBy == ProductSortingEnum.Position && manufacturerId > 0)
                {
                    //manufacturer position
                    query =
                        query.OrderBy(p => p.ProductManufacturers.FirstOrDefault(pm => pm.ManufacturerId == manufacturerId).DisplayOrder);
                }
                else if (orderBy == ProductSortingEnum.Position)
                {
                    //otherwise sort by name
                    query = query.OrderBy(p => p.Name);
                }
                else if (orderBy == ProductSortingEnum.NameAsc)
                {
                    //Name: A to Z
                    query = query.OrderBy(p => p.Name);
                }


If you are not a developer can contact me on skype for more details.
Hace 7 años
Thank you Sohel.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.