# Variants sort under variant tab for a product

**URL:** <https://forum.litium.com/t/variants-sort-under-variant-tab-for-a-product/593>\
**Category:** Questions\
**Tags:** litium-6\
**Created:** [February 14, 2019, 4:26pm UTC](https://forum.litium.com/t/variants-sort-under-variant-tab-for-a-product/593 "2019-02-14T16:26:06Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![krilin](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/krilin/32/175_2.png) [@krilin](https://forum.litium.com/u/krilin)\
**Post date:** [February 14, 2019, 4:26pm UTC](https://forum.litium.com/t/variants-sort-under-variant-tab-for-a-product/593/1 "2019-02-14T16:26:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![steve.redstorm](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/steve.redstorm/32/14_2.png) [@steve.redstorm](https://forum.litium.com/u/steve.redstorm)\
**Post date:** [February 15, 2019, 8:50am UTC](https://forum.litium.com/t/variants-sort-under-variant-tab-for-a-product/593/2 "2019-02-15T08:50:07Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![marten](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/marten/32/11_2.png) [@marten](https://forum.litium.com/u/marten)\
**Post date:** [February 18, 2019, 8:53am UTC](https://forum.litium.com/t/variants-sort-under-variant-tab-for-a-product/593/3 "2019-02-18T08:53:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![krilin](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/krilin/32/175_2.png) [@krilin](https://forum.litium.com/u/krilin)\
**Post date:** [February 18, 2019, 10:02am UTC](https://forum.litium.com/t/variants-sort-under-variant-tab-for-a-product/593/4 "2019-02-18T10:02:05Z")

</div>

Thanks, two good options!

---

<div class="post-metadata">

**Author:** ![krilin](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/krilin/32/175_2.png) [@krilin](https://forum.litium.com/u/krilin)\
**Post date:** [March 5, 2019, 9:11am UTC](https://forum.litium.com/t/variants-sort-under-variant-tab-for-a-product/593/5 "2019-03-05T09:11:45Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![steve.redstorm](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/steve.redstorm/32/14_2.png) [@steve.redstorm](https://forum.litium.com/u/steve.redstorm)\
**Post date:** [March 5, 2019, 12:30pm UTC](https://forum.litium.com/t/variants-sort-under-variant-tab-for-a-product/593/6 "2019-03-05T12:30:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![krilin](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/krilin/32/175_2.png) [@krilin](https://forum.litium.com/u/krilin)\
**Post date:** [March 6, 2019, 10:35am UTC](https://forum.litium.com/t/variants-sort-under-variant-tab-for-a-product/593/7 "2019-03-06T10:35:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![krilin](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/krilin/32/175_2.png) [@krilin](https://forum.litium.com/u/krilin)\
**Post date:** [March 6, 2019, 1:46pm UTC](https://forum.litium.com/t/variants-sort-under-variant-tab-for-a-product/593/8 "2019-03-06T13:46:04Z")

</div>

Bug reported:  
[https://docs.litium.com/support/bugs/bug\_details?id=45168](https://docs.litium.com/support/bugs/bug_details?id=45168)
