Difference between revisions of "Extending the Store Search for Sku"

From AbleCommerce Wiki
Jump to: navigation, search
 
Line 19: Line 19:
 
</pre>
 
</pre>
 
</code>
 
</code>
 +
 +
[[Category:AbleCommerce 7]]

Latest revision as of 11:27, 15 August 2013

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);