Set default search to include item description

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
9 anni tempo fa
Hi, we are using NopCommerce 3.30, it seems the default search only search item title. Is it possible to set the default search including item description and SKU #. SKU # searchable is very important for us (both customer and our employees), as we save the item parts # in the SKU field. When customers call in, they like to give us that number.

Thanks!
9 anni tempo fa
luothree wrote:
Hi, we are using NopCommerce 3.30, it seems the default search only search item title. Is it possible to set the default search including item description and SKU #. SKU # searchable is very important for us (both customer and our employees), as we save the item parts # in the SKU field. When customers call in, they like to give us that number.

Thanks!


Go to Presentation (or Nop.Web) / Views / Catalog / SearchBox.cshtml

Open this file and add the following code right above submit button:


 <input id="As" name="As" type="checkbox" value="true" checked="checked" hidden="true" tabindex="14">
    <input id="Sid" name="Sid" type="checkbox" value="true" checked="checked" hidden="true" tabindex="22">
  



So, your code should look like this:

<input type="text" class="search-box-text" id="small-searchterms" autocomplete="off" value="@searchTooltip" name="q" />
   @Html.Widget("searchbox_before_search_button")
<input id="As" name="As" type="checkbox" value="true" checked="checked" hidden="true" tabindex="14">
    <input id="Sid" name="Sid" type="checkbox" value="true" checked="checked" hidden="true" tabindex="22">
   <input type="submit" class="button-1 search-box-button" value="@T("Search")" />
   <script type="text/javascript">
       $(document).ready(function() {
           $("#small-searchterms").focus(function() {
               if (this.value == '@T("Search.SearchBox.Tooltip")') {
                   this.value = '';
               }
           });

           $("#small-searchterms").blur(function() {
               if (this.value == '') {
                   this.value = '@searchTooltip';
               }
           });
       });
9 anni tempo fa
Thanks a lot to L.K. Very nice!
9 anni tempo fa
luothree wrote:
Thanks a lot to L.K. Very nice!


You're welcome :)
8 anni tempo fa
Does this work for v3.40?
8 anni tempo fa
L.K wrote:
Hi, we are using NopCommerce 3.30, it seems the default search only search item title. Is it possible to set the default search including item description and SKU #. SKU # searchable is very important for us (both customer and our employees), as we save the item parts # in the SKU field. When customers call in, they like to give us that number.

Thanks!

Go to Presentation (or Nop.Web) / Views / Catalog / SearchBox.cshtml

Open this file and add the following code right above submit button:


 <input id="As" name="As" type="checkbox" value="true" checked="checked" hidden="true" tabindex="14">
    <input id="Sid" name="Sid" type="checkbox" value="true" checked="checked" hidden="true" tabindex="22">
  



So, your code should look like this:

<input type="text" class="search-box-text" id="small-searchterms" autocomplete="off" value="@searchTooltip" name="q" />
   @Html.Widget("searchbox_before_search_button")
<input id="As" name="As" type="checkbox" value="true" checked="checked" hidden="true" tabindex="14">
    <input id="Sid" name="Sid" type="checkbox" value="true" checked="checked" hidden="true" tabindex="22">
   <input type="submit" class="button-1 search-box-button" value="@T("Search")" />
   <script type="text/javascript">
       $(document).ready(function() {
           $("#small-searchterms").focus(function() {
               if (this.value == '@T("Search.SearchBox.Tooltip")') {
                   this.value = '';
               }
           });

           $("#small-searchterms").blur(function() {
               if (this.value == '') {
                   this.value = '@searchTooltip';
               }
           });
       });



Hi
I'm new in NopCommerce Ver 3.7 and unfortunately there is not  "input id="As"  or input id="Sid"  "  in my SearchBox.cshtml
#1: what can I do for this new version?
#2: if I introduce a new field  dbo.Product.[AlternativeSerchItems] in the end of product table next to the [UpdatedOnUtc] Field , what section of the above code must changed?


Sincerely
Masoud
7 anni tempo fa
Hi! I tried to use this code and it set only Search In product descriptions without set the Advanced search, so it does not find the itens in product description! Can you help on this?

This is my code in SearchBox.cshtml

@model SearchBoxModel
@using Nop.Web.Models.Catalog;

@using (Html.BeginRouteForm("ProductSearch", FormMethod.Get, new { @class = "navbar-form navbar-left", id = "small-search-box-form"}))
{
    <div class="form-group">
        <input type="text" class="search-nav form-control" id="small-searchterms" autocomplete="off" placeholder="@T("Search.SearchBox.Tooltip")" name="q" />
        @Html.Widget("searchbox_before_search_button")
    <input id="As" name="As" type="checkbox" value="true" checked="checked" hidden="true" tabindex="14">
    <input id="Sid" name="Sid" type="checkbox" value="true" checked="checked" hidden="true" tabindex="22">
        <input type="submit" class="btn search-box-button" value="" />
        @if (Model.SearchTermMinimumLength > 0)
        {
            <script type="text/javascript">
                $("#small-search-box-form").submit(function(event) {
                if ($("#small-searchterms").val() == "") {
                    alert('@Html.Raw(HttpUtility.JavaScriptStringEncode(T("Search.EnterSearchTerms").Text))');
                    $("#small-searchterms").focus();
                    event.preventDefault();
                }
            });
            </script>
        }
        @if (Model.AutoCompleteEnabled)
        {
        <text>
            <script type="text/javascript">
                $(document).ready(function() {
                    $('#small-searchterms').autocomplete({
                            delay: 500,
                            minLength: @(Model.SearchTermMinimumLength.ToString()),
                            source: '@(Url.RouteUrl("ProductSearchAutoComplete"))',
                            appendTo: '.search-box',
                            select: function(event, ui) {
                                $("#small-searchterms").val(ui.item.label);
                                setLocation(ui.item.producturl);
                                return false;
                            }
                        })
                        .data("ui-autocomplete")._renderItem = function(ul, item) {
                            var t = item.label;
                            //html encode
                            t = htmlEncode(t);
                            return $("<li></li>")
                                .data("item.autocomplete", item)
                                .append("<a>@(Model.ShowProductImagesInSearchAutoComplete ? Html.Raw("<img src='\" + item.productpictureurl + \"'>") : null)" + t + "</a>")
                            .appendTo(ul);
                    };
                });
            </script>
        </text>
        }

        @Html.Widget("searchbox")
    </div>
}
7 anni tempo fa
Looking for this in 3.9
7 anni tempo fa
I don't like to change the original sources, so I added and registered a new ProductService in my plugin,
copied the original ProductService and added this line in the Search function on line +/- 500

searchDescriptions = true;

Tested this only on version 3.90
2 anni tempo fa
whats the solution for version 4.3 ??? any help please?
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.