Featured Products - choosing/deleting of 10th item on first page error / bug?
1.5.7c, clone-a-template (responsive) , display logs, SiteMapXML.
While doing some clean up of featured products, I found I cannot choose "delete" or "information" on the tenth (10th) item on the first page. Selecting edit works fine, but choosing to delete or information results in a skip to page 2 (and no ID# product chosen on page 2). The tenth item on my second and third pages work fine.
I checked my logs for errors and found none.
Re: Featured Products - choosing/deleting of 10th item on first page error / bug?
I can confirm this behavior. In a test 1.5.7c, I made sure that I had more than 10 feature products. I tried to select the row for the one at the bottom of the list (#10) and was sent to page 2 of the featured products. the same happens if you try to click on the delete icon or the info icon. if you click on the edit icon you will get the edit page for that product to adjust the dates.
I also adjusted the maximum number of featured products to show on that page to 9 and test and get the same behavior it doesn't matter how many are in the list, whichever one is last on page 1 you can not select it, it instead treats it as if you click the next text link in the row below
Re: Featured Products - choosing/deleting of 10th item on first page error / bug?
Update, the same behavior happens on the specials page
Re: Featured Products - choosing/deleting of 10th item on first page error / bug?
This problem does not occur on ZC158, but that is not much help as the files are very different to compare and I don't find a PR that addressed this issue specifically.
Re: Featured Products - choosing/deleting of 10th item on first page error / bug?
who loves ya?
one needs to comment out line 361:
https://github.com/zencart/zencart/b...tured.php#L361
PHP Code:
//from
$_GET['page'] = round((($check_count / MAX_DISPLAY_SEARCH_RESULTS_FEATURED_ADMIN) + (fmod_round($check_count, MAX_DISPLAY_SEARCH_RESULTS_FEATURED_ADMIN) !== 0 ? .5 : 0)));
//to
// $_GET['page'] = round((($check_count / MAX_DISPLAY_SEARCH_RESULTS_FEATURED_ADMIN) + (fmod_round($check_count, MAX_DISPLAY_SEARCH_RESULTS_FEATURED_ADMIN) !== 0 ? .5 : 0)));
same thing in specials.
best.
Re: Featured Products - choosing/deleting of 10th item on first page error / bug?
:hug: :thumbsup: in the specials.php file it is line 435 that needs to be comment out
Re: Featured Products - choosing/deleting of 10th item on first page error / bug?
I'd actually recommend that since commenting out that portion of code pretty much makes it useless and the following resolves the reported issue to change admin/featured.php line 354: https://github.com/zencart/zencart/b...tured.php#L354
From:
To:
As this section of code only executes when either on page 1 (as declared by the link) or "effectively" on page 1 (because no page has been provided), when the code that was commented out is executed, now it will provide stay on page 1 when the last item in the list is at issue, this also resolves a similar problem where either the fID is "known" but the page is not (portion of the issue being addressed by this part of the code) then the calculation will also ensure that the correct page is used.
Here was the test I did:
Default/demo store
Set configuration->maximum Values->Featured Products - Number to Display Admin to 4
(Why? because I wanted to be sure that I had at least 3 pages against which to test as attempting a page number greater than the maximum number of pages causes the current page to become the last one available)
I then went to the featured products area which resulted in 3 pages with 4 product on each of the first two and 2 product on the last.
I clicked on the last product of the first page, it effectively showed me page 2 product data, but the browser link still had page 1 related items, in this case:
index.php?cmd=featured&page=1&fID=3
BUT, as noted, the "page=2" type data appears with no right sidebox.
Now, the "missing page" condition, if take note of the last item on that list, it has an fID of 9. So, first click on that line and the browser link changes to:
index.php?cmd=featured&page=2&fID=9
And no issues, right?
Well, now remove the 2 from page= so that reads:
index.php?cmd=featured&page=&fID=9
And again, the wrong (next) page of data appears (bottom says 3 of 3) and again a blank right side.
Further test (identifying another unfortunate modification in this area) is that if the page parameter is completely removed:
index.php?cmd=featured&fID=9
Now the result is page 1 (note 1 of 3 at the bottom) and again a blank right side... This last part is further a change/difference applied to the recent code change in this area and necessitates changing (restoring?) line 350: https://github.com/zencart/zencart/b...tured.php#L350
From:
Code:
if ((isset($_GET['page']) && ($_GET['page'] == '1' || $_GET['page'] == '')) && isset($_GET['fID']) && $_GET['fID'] != '') {
to:
Code:
if ((empty($_GET['page']) || $_GET['page'] == '1') && !empty($_GET['fID'])) {
An idea is that one should be able to direct/redirect to the featured (and specials) pages without having to know on what page a product is listed/identified and the user should be shown the item in the list at the correct page...
Now if the provided fID doesn't exist, what ends up happening is that the last page is shown. Is that best? Ehh.. It's something... Probably would be better to give some sort of admin message indicating the absence of that fID value, but...
At least this way (the two changes above), one arrive at the correct page for an fID when either the page is blank, 1, or missing from the link. It might be even a little better to "always" do a "page check" so that the likes of: index.php?cmd=featured&page=3&fID=8 would show the correct page even though page 3 was attempted...
Re: Featured Products - choosing/deleting of 10th item on first page error / bug?
@mc12345678
finding where the error is, in my experience, is most times harder than recommending a solution.
i am not sure what code base we live in where modifying a GET var for a page number is ever a good idea.
while i have no doubt your solution works (i have not tested), other than sanitizing the GET vars, modifying a GET var is, to me, bad coding and makes for a maintenance nightmare.
just my 2 cents.
people can feel free to do whatever they want to their code....
Re: Featured Products - choosing/deleting of 10th item on first page error / bug?
Quote:
Originally Posted by
carlwhat
@mc12345678
finding where the error is, in my experience, is most times harder than recommending a solution.
i am not sure what code base we live in where modifying a GET var for a page number is ever a good idea.
while i have no doubt your solution works (i have not tested), other than sanitizing the GET vars, modifying a GET var is, to me, bad coding and makes for a maintenance nightmare.
just my 2 cents.
people can feel free to do whatever they want to their code....
Well, the split_page_results class at its core modifies whatever "page" indicator is used, whether its just a php variable or a $_GET variable when/if the provided page exceeds the calculated number of pages and it appears as if every use of the class except in the admin's coupon restrict code uses a $_GET which means that it could/would be modified if the value provided exceeds the calculated value.
As to "modifying" a $_GET variable, I mean, in one respect (and yes a bit overboard/cheeky) every time a link is generated the $_GET variable is being modified... In one aspect (still cheeky) as if saying shouldn't use any parameters whatsoever on a link.:P
Re: Featured Products - choosing/deleting of 10th item on first page error / bug?
Quote:
Originally Posted by
carlwhat
@mc12345678
finding where the error is, in my experience, is most times harder than recommending a solution.
i am not sure what code base we live in where modifying a GET var for a page number is ever a good idea.
while i have no doubt your solution works (i have not tested), other than sanitizing the GET vars, modifying a GET var is, to me, bad coding and makes for a maintenance nightmare.
just my 2 cents.
people can feel free to do whatever they want to their code....
On a more serious note though, this modification of the page "number" as applied in the two programs is a bit of a sanitation... Again, why just on page=1 and in a way no page is given, ehh. But the approach is to set the page to the correct value for the provided fID. It's just that the "edge" case was missed...