Try our conversational search powered by Generative AI!

Add new filters to Quicksilver

Vote:
 

Hi!

I am trying to figure out how filtering products in Quicksilver works.

I have added a property to a variant:

[CatalogContentType (
        GUID = "D9181050-28AE-4B31-8498-B5D831F13610",
        MetaClassName = "TestVariant",
        DisplayName = "Test Variant",
        Description = "Display Test variant" )]
    public class TestVariant : FashionVariant
    {
        [Ignore]
        [ScaffoldColumn ( false )]
        public override string Size { get; set; }

        [Searchable]
        [CultureSpecific]
        [Tokenize]
        [IncludeInDefaultSearch]
        [BackingType(typeof(PropertyBoolean))]
        [Display(Name = "Prop1-test", Order = 10)]
        public virtual bool Prop1 { get; set; }
    }

And this property is visible in the variant edit page. But how can I add this to the filters on the catalog page (like Color, Size on existing fashion variants )?

I have added filter to the config file:

<filter field="Prop1">
      <Descriptions defaultLocale="en">
        <Description locale="en">Prop1</Description>
        <Description locale="sv">Prop1</Description>
        <Values>
          <SimpleValue key="true" value="true">
            <Descriptions defaultLocale="en">
              <Description locale="en">true</Description>
              <Description locale="sv">true</Description>
            </Descriptions>
          </SimpleValue>
          <SimpleValue key="false" value="false">
            <Descriptions defaultLocale="en">
              <Description locale="en">false</Description>
              <Description locale="sv">false</Description>
            </Descriptions>
          </SimpleValue>
        </Values>
      </Descriptions>
    </filter>

I am also adding them to document fields in the SearchDocumentController:

private void AddTestProperties1(RestSearchDocument document, IEnumerable<TestVariant> variants)
        {
            var props = new List<bool>();
            foreach (var testVariant in variants)
            {
                if (!props.Contains(testVariant.Prop1))
                {
                    props.Add(testVariant.Prop1);
                    document.Fields.Add(new RestSearchField("Prop1", testVariant.Prop1.ToString().ToLower()));
                }
            }
        }

Even after indexing the search index (in commerce and in admin) nothing happens.

And why does the filter option for sizes dissapear when I select shoes?

#207749
Edited, Oct 01, 2019 16:33
Vote:
 

I have done some debugging and I see that the SearchFilterHelper returns 4 filters : site, color, brand and top_category_name.

Why my added filter is ignored?

#207752
Oct 01, 2019 18:20
Vote:
 

After some digging I habe found the issue:

My filter declaration in the config file was malformed. Also, the field name should be all lowercase.

Then there are three indexers that need to index my instances, so I had to copy pase my AddTestProperties1 method three times.

And that is it.

#207784
Oct 03, 2019 10:26
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.