Variants sort under variant tab for a product

Hi!

Under the variant tab for a Product we have a lot of variants the order is a disaster! I know I can drag and drop to rearrange, but that will take like forever.
Is it possible to write some magic code that sorts everything in article number order or alphabetical order? Back to basic so to say and after that the user can drag and drop to deside the order of thing?

Thanks!

/Kristoffer

Litium version: 6.2.2

Fetch the Productvariants and change the SortIndex (int) according to logic you want.
(You “might” need to refresh cache after)
But remember after, if you swap them manually in the BO then they will be changed anyway.

You can also use excel export/import to sort the variants. Export your product with all variants then sort them in excel where you can sort on any column or property you like, then when you import the file again just check the box for: Sort variants according to the order set in the Excel file.

And it is possible to write code to sort variants that can trigger on events or run as a scheduled task.

Thanks, two good options!

@marten I cannot get this to work? I exported a product. Resorted the variants in the Excel, and then imported and checked in “Sort variants according to the order …” but the order under the variant tab is still the same? Import says that 1 Product and 120 variants har been updated.
My Excel file only has two columns but I guess that should be enough:

|Artikelnummer|VariantAv|
|VG-00297||
|00297055301|VG-00297|

Any ideas?

Thanks!

/Kristoffer

The order ought to be changed according to your excel sheet when you check the ordering checkbox.

That is what I thought. I will report a bug for this.

1 Like

Bug reported:
https://docs.litium.com/support/bugs/bug_details?id=45168

1 Like