Developer forum

Forum » Dynamicweb 10 » IndexBuilderExtender in DW10

IndexBuilderExtender in DW10

Mario Santos Dynamicweb Employee
Mario Santos
Reply

Hi there,

We are running into an issue where we are not able to use IndexBuilderExtender to add new fields to the index, we see code running using debug and actual entry added to IndexDocument, but then is not stored.

I have tried multiple approaches such as:
- Not create a field in UI
- Create a indexed and stored field in UI without source

Any thoughts? 

public class IndexBuilderExtender : IndexBuilderExtenderBase<Dynamicweb.Ecommerce.Indexing.ProductIndexBuilder>
{
    public override void ExtendDocument(IndexDocument doc)
    {
        AddToDocument(doc, "IsDealerPortalProduct", true);
    }

    private static void AddToDocument(IndexDocument doc, string docFieldName, object value)
    {
        if (doc.ContainsKey(docFieldName))
        {
            doc[docFieldName] = value;
        }
        else
        {
            doc.Add(docFieldName, value);
        }
    }
}

 

BR Mario


Replies

 
Mario Santos Dynamicweb Employee
Mario Santos
Reply

bump, anyone?

 
Roald Haahr
Reply

Hej Mario,

In DW9 there is a '+' icon next to the source selector in the index field configuration, which allows you to add the placeholder source in the UI. However, that seems not to be an option in DW10 yet. If anybody from DW is reading this, please add this feature.

I just had a similar problem which I ended up solving by adding a placeholder source in the Source list directly in the HTML. Find your IsDealerPortalProduct field in the index configuration. Set it to Indexed and Stored. Right click the Source selector field and inspect it. Find the options for the field in the HTML and add your own <li> to the <ul> of options. Fill data-value attribute of the <li> with your placeholder source's system name (in your case IsDealerPortalProduct) and set as the name of the option as well. Select the option in the source selector and press save. In my case it started populating my ProductInStock field with the correct data from the IndexBuilderExtender. The next time you enter the field configuration, it will show an error, saying that the field doesn't exist anymore, but in my case it works anyway. I hope this workaround works for you as well.

Kind regards
Roald

 

 
Mario Santos Dynamicweb Employee
Mario Santos
Reply

Thanks Roald, that did the trick. Another option is to modify the index file directly and set the Source attribute. It is a workaround, hopefully we will hear from platform team on this.

<Field Source="IsDealerPortalProduct" Name="IsDealerPortalProduct" SystemName="IsDealerPortalProduct" Type="System.Boolean" Boost="" Stored="true" Analyzed="false" Indexed="true" Facetable="false" />

BR Mario

 
Roald Haahr
Reply

Good idea. I prefer your workaround to the one I suggested. It looks like the safer and most correct way to solve the problem.

Kind regards,
Roald

 
Oleg Rodionov Dynamicweb Employee
Oleg Rodionov
Reply

Hi,

new task #26805 has been submitted against the issue to extend field's source with radio has two options - first is related to curent one used and new one related to using text field to input. Thanks.

BR, Oleg QA

 

You must be logged in to post in the forum