Developer forum

Forum » Development » Wrong ordering of products from index

Wrong ordering of products from index

Anders Ebdrup
Anders Ebdrup
Reply

Hi DW,

 

We see wrong ordering of products on the initial display of products when we have set a custom order, but after the page is reloaded then the sort order is correct.

It seems to be caused by this code in ProductService.vb:

        Friend Function GetByAutoIDs(autoIDs As Int64()) As IEnumerable(Of Product)
            Dim products As New List(Of Product)
            Dim missingAutoIds As New List(Of Long)()

            For Each autoId As Long In autoIDs
                'Lookup the cachekey in the autoId mapping
                Dim cacheKey As String = Nothing
                If Not AutoIdIndex.TryGetValue(autoId, cacheKey) Then
                    missingAutoIds.Add(autoId)
                    Continue For
                End If

                Dim cacheProduct As Product = LookupProductInCache(cacheKey)

                If cacheProduct IsNot Nothing Then
                    products.Add(cacheProduct)
                Else
                    missingAutoIds.Add(autoId)
                End If
            Next

            Dim databaseProducts As IEnumerable(Of Product) = Repository.GetProductsByAutoIDs(missingAutoIds.ToArray())

            For Each databaseProduct In databaseProducts
                AddProductToCache(databaseProduct)
            Next

            products.AddRange(databaseProducts)

            Return products
        End Function

 

Here the products need to be reordered according to the index of each autoid, as the initial sort order will be messed up with products from cache and products from the database

 

We are experiencing this issue on 9.4.7 and will be happy for a quick fix :-)

 

Best regards, Anders


Replies

 
Kristian Kirkholt Dynamicweb Employee
Kristian Kirkholt
Reply
This post has been marked as an answer

Hi Anders

The problem #48754 regarding GetByAutoId does not respect sort order has been resolved in Dynamicweb version 9.4.9

You are able to find this build in the download section: http://doc.dynamicweb.com/releases-and-downloads/releases

Let me know if you need any more help regarding this

Kind Regards
Dynamicweb Support
Kristian Kirkholt

Votes for this answer: 1

 

You must be logged in to post in the forum