Page 1 of 1

Error on Category View with More than one Page of Products

Posted: Thu Aug 20, 2020 8:22 pm
by Eleventh_Earl
Hi Experts

I am encountering a problem with OC 2.3.0.2 in the category view. When there are too many products for one page, I get a link to page 2, 3 etc. That works fine. However, when I'm viewing page 2 of the category, then click the link to return to page 1, I get the following errors displayed at the top of the browser.

Warning: A non-numeric value encountered in .../catalog/controller/product/category.php on line 174
Warning: A non-numeric value encountered in .../catalog/controller/product/category.php on line 363
Warning: A non-numeric value encountered in .../catalog/controller/product/category.php on line 363
Warning: A non-numeric value encountered in .../catalog/controller/product/category.php on line 363
Warning: A non-numeric value encountered in .../catalog/controller/product/category.php on line 371
Warning: A non-numeric value encountered in .../catalog/controller/product/category.php on line 375

The relevant lines from the category.php file are below.

Line 174 => 'start' => ($page - 1) * $limit,

Line 363 => $data['results'] = sprintf($this->language->get('text_pagination'), ($product_total) ? (($page - 1) * $limit) + 1 : 0, ((($page - 1) * $limit) > ($product_total - $limit)) ? $product_total : ((($page - 1) * $limit) + $limit), $product_total, ceil($product_total / $limit));

Line 371 => $this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id'] . '&page='. ($page - 1), true), 'prev');
}

Line 375 => $this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id'] . '&page='. ($page + 1), true), 'next');
}

I'm more than a little out of my depth with this one. Any suggestions as to what may be causing the error, or ideas on how to correct it would be really appreciated!

Thanks folks.

Re: Error on Category View with More than one Page of Products

Posted: Thu Aug 20, 2020 11:22 pm
by IP_CAM
Well, with the exception of this line:

Code: Select all

Line 174 => 'start' => ($page - 1) * $limit,
none of the other lines as quoted matches the 2.3.0.2 default File content
you show. Something must therefore have been changed and/or added in your

Code: Select all

controller/product/category.php
File, and it's not possible, to be of any assistance this way...

Re: Error on Category View with More than one Page of Products

Posted: Fri Aug 21, 2020 4:22 am
by Eleventh_Earl
Thanks for the reply. I have uploaded a fresh copy of the controller/product/category.php to eliminate any changes that may have been made.

I now get the same error messages, but with different line numbers giving the same errors.

174 => 'start' => ($page - 1) * $limit,
349 => $data['results'] = sprintf($this->language->get('text_pagination'), ($product_total) ? (($page - 1) * $limit) + 1 : 0, ((($page - 1) * $limit) > ($product_total - $limit)) ? $product_total : ((($page - 1) * $limit) + $limit), $product_total, ceil($product_total / $limit));
357 => $this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id'] . '&page='. ($page - 1), true), 'prev');
361 => $this->document->addLink($this->url->link('product/category', 'path=' . $category_info['category_id'] . '&page='. ($page + 1), true), 'next');

I had hoped that after uploading a new file from a fresh download (prompted by your comments) that the issue would resolve, but only the line numbers have changed.

Re: Error on Category View with More than one Page of Products

Posted: Sat Aug 29, 2020 11:20 am
by khnaz35
Have your host change the PHP version ? what is your current version?

Re: Error on Category View with More than one Page of Products

Posted: Sat Aug 29, 2020 5:04 pm
by johnp
Try uploading a clean copy of OC into a sub folder. Something like /clean. Amend the config.php and admin/config.php and see if you can connect to the current database. That will help identify where the problem sits. Also, can you list your PHP version.

Re: Error on Category View with More than one Page of Products

Posted: Sat Aug 29, 2020 5:34 pm
by xxvirusxx
You need to add (int) on some locations..
https://github.com/opencart/opencart/pull/7785/files

Re: Error on Category View with More than one Page of Products

Posted: Sat Aug 29, 2020 5:39 pm
by khnaz35
xxvirusxx wrote:
Sat Aug 29, 2020 5:34 pm
You need to add (int) on some locations..
https://github.com/opencart/opencart/pull/7785/files
Some locations mean? Same lines where he had warning

Re: Error on Category View with More than one Page of Products

Posted: Sat Aug 29, 2020 5:42 pm
by xxvirusxx
khnaz35 wrote:
Sat Aug 29, 2020 5:39 pm
Some locations mean?
If you click on that link you will see files names....and where...

Re: Error on Category View with More than one Page of Products

Posted: Sat Aug 29, 2020 5:48 pm
by khnaz35
xxvirusxx wrote:
Sat Aug 29, 2020 5:42 pm
khnaz35 wrote:
Sat Aug 29, 2020 5:39 pm
Some locations mean?
If you click on that link you will see files names....and where...
Thanks for clarifying, he must be able to solved it now