Developer forum

Forum » Development » Missing VariantGroupProductRelationSorting

Missing VariantGroupProductRelationSorting

Anders Ebdrup
Anders Ebdrup

Dear Dynamicweb,


Vi have an issue with "wrong" variant group sorting (please find this image:, but the sort order is correct in the database.

Can you please add this section: "ORDER BY VariantGroupProductRelationSorting" to the line marked with red


        Public Overridable Function GetAllVariantGroupProductRelations() As IEnumerable(Of VariantGroupProductRelation)
            Dim sqlBuilder As New CommandBuilder()
            sqlBuilder.Add("SELECT * FROM EcomVariantgroupProductRelation ")

            Dim result As New List(Of VariantGroupProductRelation)()
            Using dataReader As IDataReader = Database.CreateDataReader(sqlBuilder)
                While dataReader.Read()
                    Dim relation As VariantGroupProductRelation = FillVariantGroupProductRelation(dataReader)
                End While
            End Using

            Return result
        End Function


Best regards, Anders



Olga Shedko Dynamicweb Employee
Olga Shedko

Hello Anders,

New tfs #86990 has been added for fixing that one to the next hot-fix release. Thank you.

Best regards,

Olga | QA


Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen

Hi Anders

We are just looking at the implications of this change - it is not a simple fix as it would have bad consequences for those solutions which happens to not have a sort value. Which is everyone.

We might be able to enable the sorting. But there is so much logic related to this that it would a very high risk change that needs a lot of testing. I agree that the lack of an order by statement particular on this table is a problem wether it be the sortorder or the order of which the records are created (which is how it works now).

As a workaround in the meantime could be to add a clustered index on the productid/sort columns.

BR Nicolai

Dynamicweb Employee
Stanislav Smetanin

Hi Anders,

Looks like the error which you found in Ecommerce product list is not related with wrong sort order. I think that some variant option from Settings -> Ecommerce -> Product catalog -> Variants was removed, but was not removed from the [EcomVariantOptionsProductRelation] table. 

So "wrong order" is because EcomVariantOptionsProductRelation table has variant-product combination pair, but this variant option is not exist (if this is the reason of problem).

So you can check it by next sql query:

 SELECT DISTINCT VariantOptionsProductRelationProductId FROM  [EcomVariantOptionsProductRelation]

 WHERE VariantOptionsProductRelationVariantId NOT IN 
SELECT VariantOptionsProductRelationVariantId FROM [EcomVariantOptionsProductRelation]
  INNER JOIN EcomVariantsOptions ON EcomVariantsOptions.VariantOptionId = [EcomVariantOptionsProductRelation].VariantOptionsProductRelationVariantId
 ) AND VariantOptionsProductRelationProductId = 'YourProductId'


Could you please run it and say if your product in this returned list?


Kind regards.

Anders Ebdrup
Anders Ebdrup

Dear Stanislav,


Nicolai suggestion solves the issue for now, and your query returns our product id.


Best regards, Anders


You must be logged in to post in the forum