Extending the Store Search for Sku

From AbleCommerce Wiki
Revision as of 11:27, 15 August 2013 by Sohaib (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The search option which appears in the top border of the customer side allows for a search by name keyword. You can enhance this search to support Sku as well. I know you can search by name, description or sku in the advanced search, but that's an extra click for the customer to go to this. Bellow is the code example that how to do this job.

Edit the ConLib/SearchPage.ascx.cs and locate the following line of code

ProductList.DataSource = ProductDataSource.NarrowSearch(_Keywords, this.CategoryId, _ManufacturerId, 0, 0, _PageSize, (_HiddenPageIndex * _PageSize), SortResults.SelectedValue);

and replace it with the following lines of code

int startIndex = (_HiddenPageIndex * _PageSize);
        if(startIndex == (-1*_PageSize))
            startIndex = 0;
        ProductList.DataSource = ProductDataSource.AdvancedSearch(_Keywords, this.CategoryId, _ManufacturerId, true, true, true, 0, 0, _PageSize, startIndex, SortResults.SelectedValue);