R7 search paging bug

For general questions and discussions specific to the AbleCommerce GOLD ASP.Net shopping cart software.
Post Reply
User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

R7 search paging bug

Post by jmestep » Tue Jun 03, 2014 7:52 am

We have some sites in development in R7 and we are running into paging problems on the mobile search page. I wanted to post here to see if it had been reported already before I went digging thru code and submitted a bug.
I have tried the mobile search on one of my local sites where I have able sample products, plus a copy of a few of the products, totaling 44 products. I haven't done any customizations on the mobile pages.
When I am in FTS search mode and search for b*, I get 2 pages with 10 products each. Both pages have all the same products except for 1. All in one printer p33 shows on first page results but computer training p 32 shows on second page instead.
When I search for b on SQL search, both pages show the same 10 products.
See the attached files showing the paging.
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: R7 search paging bug

Post by jmestep » Tue Jun 03, 2014 7:56 am

I just checked the R4 live site for one of these sites and am seeing the problem there.
Go to http://www.cheshirehorse.com/mobile/search.aspx and search for brass horse hook.
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

nadeem
Captain (CAPT)
Captain (CAPT)
Posts: 258
Joined: Tue Jul 31, 2012 7:23 pm

Re: R7 search paging bug

Post by nadeem » Tue Jun 17, 2014 1:47 am

To fix this issue, made the following updates to Website/Mobile/Search.aspx.cs Page_Load method:

Locate the following line of code

Code: Select all

_lastPageIndex = ((int)Math.Ceiling(((double)_searchResultCount / (double)_pageSize))) - 1;
and replace with

Code: Select all

_lastPageIndex = ((int)Math.Ceiling(((double)_searchResultCount / (double)_pageSize))) - 1;
if (_hiddenPageIndex < 0) _hiddenPageIndex = 0;
Similarly, locate the following code

Code: Select all

//bind search results
int startIndex = (_hiddenPageIndex * _pageSize);
if (startIndex < 0) startIndex = 0;
if (startIndex > _lastPageIndex) startIndex = _lastPageIndex;
var products = ProductDataSource.AdvancedSearch(_keywords, _categoryId, _manufacturerId, true, true, true, 0, 0, _pageSize, startIndex, SortResults.SelectedValue);
and replace with

Code: Select all

//bind search results
var products = ProductDataSource.AdvancedSearch(_keywords, _categoryId, _manufacturerId, true, true, true, 0, 0, _pageSize, (_hiddenPageIndex * _pageSize), SortResults.SelectedValue);

jonw2m
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 35
Joined: Thu Sep 15, 2011 9:00 pm

Re: R7 search paging bug

Post by jonw2m » Wed Jun 18, 2014 6:04 am

I tried the suggested patch on a R7 and there's nothing between the page numbers (see image)
Image

nadeem
Captain (CAPT)
Captain (CAPT)
Posts: 258
Joined: Tue Jul 31, 2012 7:23 pm

Re: R7 search paging bug

Post by nadeem » Thu Jun 19, 2014 5:25 am

I have tested same code in R6 build, new installed R7 builds and R8. It is working fine in all. I was able to reproduce this issue once on an already installed R7 build. This isn't due to the code fix, this is something else happening in R7, not sure what it is.
Are you working on local development copy or on a live site? You might need to clean asp.net temporary files and recycle application pool.

Do one thing more, revert all the above changes, locate and remove this line of code

Code: Select all

if (startIndex > _lastPageIndex) startIndex = _lastPageIndex;
It will work the same way. This suggestion is only to make sure the changes are applied to your application and make any difference to the page display?

jonw2m
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 35
Joined: Thu Sep 15, 2011 9:00 pm

Re: R7 search paging bug

Post by jonw2m » Fri Jun 20, 2014 5:11 am

Hi Nadeem,

This was happening on a dev site, but not local. We were also able to replicate on other R7 sites both live and local.
Your last suggestion resolved the duplicate pages.

Now I noticed a new odd behavior: While browsing through a search result, if we're - let's say on page 3 and search for a new keyword, the search displays correct results, but goes directly on page 3 (or any other page we were previously). The querystring does not change (including the keyword) until we click on a new page.

Thank you for your help.

nadeem
Captain (CAPT)
Captain (CAPT)
Posts: 258
Joined: Tue Jul 31, 2012 7:23 pm

Re: R7 search paging bug

Post by nadeem » Fri Jun 20, 2014 7:44 am

Jon, You are right about this odd behavior. To fix this do the following things:

Locate the following line in mobile/search.aspx

Code: Select all

<asp:Button ID="KeywordButton" runat="server" Text="GO" EnableViewState="false" UseSubmitBehavior="false" ValidationGroup="SearchCriteria" />
and replace with

Code: Select all

<asp:Button ID="KeywordButton" runat="server" Text="GO" EnableViewState="false" OnClick="GoButton_Click" UseSubmitBehavior="false" ValidationGroup="SearchCriteria" />
and add the following code in mobile/search.aspx.cs just below the page_load method.

Code: Select all

protected void GoButton_Click(object sender, EventArgs e)
{
   if (!string.IsNullOrEmpty(_keywords))
      {
          Response.Redirect("Search.aspx?k=" + _keywords);
      }
    Response.Redirect("Search.aspx");
}

jonw2m
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 35
Joined: Thu Sep 15, 2011 9:00 pm

Re: R7 search paging bug

Post by jonw2m » Mon Jun 23, 2014 1:16 pm

Great.

Thank you Nadeem.

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: R7 search paging bug

Post by jmestep » Tue Jun 24, 2014 3:31 am

Nadeem, have you registered a bug report or should we do that?
Thanks
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

nadeem
Captain (CAPT)
Captain (CAPT)
Posts: 258
Joined: Tue Jul 31, 2012 7:23 pm

Re: R7 search paging bug

Post by nadeem » Tue Jun 24, 2014 10:27 pm

Yes, a bug report is already registered and fixed for R9.

Post Reply