# Prevent accelerator variant grouping when grouping field is empty

**URL:** <https://forum.litium.com/t/prevent-accelerator-variant-grouping-when-grouping-field-is-empty/2212>\
**Category:** Questions\
**Tags:** litium-7\
**Created:** [September 21, 2021, 8:36am UTC](https://forum.litium.com/t/prevent-accelerator-variant-grouping-when-grouping-field-is-empty/2212 "2021-09-21T08:36:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kdxperbol](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/kdxperbol/32/513_2.png) [@kdxperbol](https://forum.litium.com/u/kdxperbol)\
**Post date:** [September 21, 2021, 8:36am UTC](https://forum.litium.com/t/prevent-accelerator-variant-grouping-when-grouping-field-is-empty/2212/1 "2021-09-21T08:36:55Z")

</div>

We would like to group variants, e.g. on the category pages, according to a product grouping field. But we only want this grouping to occur if the grouping field has a value, i.e. keep variants without a value as separate boxes on the category page.

The reason is that some products in the field template should be grouped, but others should be ungrouped. And the only way to currently achieve this is to “invent” separate values for the grouping field for all non-grouped variants, which we don’t want.

Is there an out-of-the-box accelerator way to accomplish this? If not, where in the accelerator should we look?

Litium version: 7.6.2

---

<div class="post-metadata">

**Author:** ![NilsN](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/nilsn/32/302_2.png) [@NilsN](https://forum.litium.com/u/NilsN)\
**Post date:** [September 21, 2021, 8:58am UTC](https://forum.litium.com/t/prevent-accelerator-variant-grouping-when-grouping-field-is-empty/2212/2 "2021-09-21T08:58:38Z")

</div>

Are you using Lucene or Elastic?

For Elastic, you could update `CreateModelsPerChannel` to introduce your logic and only group the variants with values and then index the variant without values as separate documents.

---

<div class="post-metadata">

**Author:** ![kdxperbol](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/kdxperbol/32/513_2.png) [@kdxperbol](https://forum.litium.com/u/kdxperbol)\
**Post date:** [September 21, 2021, 9:30am UTC](https://forum.litium.com/t/prevent-accelerator-variant-grouping-when-grouping-field-is-empty/2212/3 "2021-09-21T09:30:12Z")

</div>

> [@NilsN](#):
>
> `CreateModelsPerChannel`

Thank you.

We are using Lucene in development currently, but Elastic in production.

For Lucene it looks slightly more complicated, but it looks like I should update `VariantIndexDocumentMerger.Merge` to do the same thing as for Elastic?

---

<div class="post-metadata">

**Author:** ![NilsN](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/nilsn/32/302_2.png) [@NilsN](https://forum.litium.com/u/NilsN)\
**Post date:** [September 21, 2021, 10:05am UTC](https://forum.litium.com/t/prevent-accelerator-variant-grouping-when-grouping-field-is-empty/2212/4 "2021-09-21T10:05:06Z")

</div>

Yes, for Lucene you need to update `VariantIndexDocumentMerger` instead.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/litium/original/1X/12eddac3b8b661de1db86af10ac8151b571e6fb9.png) [@system](https://forum.litium.com/u/system)\
**Post date:** [October 19, 2021, 10:05am UTC](https://forum.litium.com/t/prevent-accelerator-variant-grouping-when-grouping-field-is-empty/2212/5 "2021-10-19T10:05:54Z")

</div>

Closed on October 19, 2021, 10:05am UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
