Developer forum

Forum » Templates » How to add Custom field to search result item?

How to add Custom field to search result item?

Erik Pettersson
Reply

Hi,

I have added one new product field named "Season" to Product Catalog. I want to show this "Season" field value in the autocompletion list of product search. I have seen that the Product No and Product name are displaying using the following html

<div class="dw-search-result-item">
            <div class="dw-search-result-picture">
                <a class="dw-search-result-url"><img class="dw-search-result-img" alt="" src="" /></a>
            </div>
            <div class="dw-search-result-productname">
                <a class="dw-search-result-productlink"><span class="dw-search-result-name"></span></a>
            </div>
            <div class="dw-search-number-wrapper">
                <!--@Translate(productnumber, "Product no.")-->
                <div class="dw-search-result-number"></div>
            </div>

 

So i tried to add html like

 <div class="dw-season-date-wrapper">
                <!--@Translate(season, "Season")-->
                <div class="dw-search-result-season"></div>
            </div>

 

I'm pretty sure it won't help in custom field case. 

What should i do to display a custom field value in the autocompletion list of search? It will be great if i get help from anyone to resolve this?

 

 

Season.JPG

Replies

 
Nicolai Høeg Pedersen
Reply

Hi Erik

If you run the debugger window of your browser, you can see the callback that the search window makes to /Admin/Public/InstantSearch.ashx that returns the results as json.

That response is rendered by the instant search javascript that is included in the template set.

If the json response contains the information you need, you can alter the js to include the data in the auto completion list.

An other option is to use the new indexing engine - there you have full freedom to alter the response and make the suggestions as you like, see: http://doc.dynamicweb-cms.com/Default.aspx?ID=642 and http://doc.dynamicweb-cms.com/Default.aspx?ID=523

​BR Nicolai

 
Erik Pettersson
Reply

Hi Nicolai,

Thanks for the great help.The /Admin/Public/InstantSearch.ashx returned json result not contains the field which i needed to show. The seond method is little bit complex. Is there any simple way? I mean how could i change the call to "/Admin/Public/InstantSearch.ashx" and to create a custom ashx json result. So that i can get all the fields 

 
Nicolai Høeg Pedersen
Reply

Hi Erik

You should not change the /InstantSearch.ashx which is part of Dynamicweb.

But you could get the code and make the change and make it custom. Attached the code for the handler.

BR Nicolai

 

You must be logged in to post in the forum