Page 1 of 1
Pagination issues
Posted: Sun Jun 06, 2010 3:08 pm
by OC2PS
Folks, I am having an issue with pagination ever since I installed Opencart, but have just gotten around to asking about it.
It seems that in any category, the number of products shown is incorrect....let me rephrase that the number of products counted is incorrect.
In the attached screenshot, you will notice that Opencart says:
Now there are 2 errors in that:
1. As you can see from the pictures, it is showing 1-11 products, not 1-12. The products shown are correct. In admin, there are 12 products in this category, however, 1 is disabled, so only 11 should be shown. Thus the photos shown are correct, but the counting is not.
2. It says total number of products are 22, and thus splits the list into 2 pages. This is incorrect. The total number of products is only 11. I suspect that this might have something to do with the fact that I am using 2 languages (EN and HU) on the shop, and Opencart may be counting number of (e.g.) product names, instead of products.
Please help!
Re: Pagination issues
Posted: Sun Jun 06, 2010 4:56 pm
by pstechnee
Hope this is problem with the counter variables which is assigned to this.
Have you did any customization in this page.
If else, I am an opencart developer. If you wish i will fix this issue.. Contact me at
soft.technee@yahoo.com
Re: Pagination issues
Posted: Sun Jun 06, 2010 5:21 pm
by OC2PS
I have made changes to the template, not to the controller.
I am using my own template, with colors etc. Plus, I have "exploded" the tabs - meaning instead of tabs, I am using descriptions, photos etc. on single flat page. I have changed a couple of links etc.
But I don't believe I have made any changes to model or controller files.
Re: Pagination issues
Posted: Sun Jun 06, 2010 5:40 pm
by pstechnee
Shall i review your code once. So that we will find the problem and resolve this..
If you have any demo instance in your application give me that url and access in my id
soft.technee@yahoo.com
We will analyse and tell u the result.
Re: Pagination issues
Posted: Sun Jun 06, 2010 6:16 pm
by OC2PS
That would be great! Thanks!
Demo URL is
http://www.csillamvilag.com/shop/arcfes ... or&lang=en
code file is attached (please rename from category.pdf to category.php).
this file is the
/shop/catalog/controller/product/category.php file
Thanks again! Really appreciate your help
Re: Pagination issues
Posted: Sun Jun 06, 2010 6:20 pm
by OC2PS
I think the error may be in line 91. Dont know what, though.
Code: Select all
$product_total = $this->model_catalog_product->getTotalProductsByCategoryId($category_id);
Re: Pagination issues
Posted: Sun Jun 06, 2010 6:23 pm
by OC2PS
The function used in the model referred to is
Code: Select all
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "product_to_category p2c LEFT JOIN " . DB_PREFIX . "product p ON (p2c.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "stock_status ss ON (p.stock_status_id = ss.stock_status_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2c.category_id = '" . (int)$category_id . "'");
return $query->row['total'];
Re: Pagination issues
Posted: Sun Jun 06, 2010 11:22 pm
by Qphoria
Is it possible that you have 22 products in one language but only 21 in the other language? the check for "count" doesn't include a language id check, which maybe should be added, but there should be other preventative measures in place to prevent that from actually needing to be there.
Re: Pagination issues
Posted: Mon Jun 07, 2010 2:14 am
by OC2PS
I only have 11 products. But Opencart pagination function thinks I have 22. That is the problem.
It splits the page into 2, and assumes that there are 12 products on page 1.
In the SQL query, it looks at the total number of products. Do products have different records in the database for different languages? Because that would explain the issue - 2 languages so products counted as 2x
Re: Pagination issues
Posted: Mon Jun 07, 2010 3:58 am
by jefrey1983
happens to me i put 9 instead because when i put 8 it only shows 7 latest product
Re: Pagination issues
Posted: Mon Jun 07, 2010 6:03 am
by OC2PS
Is there a way to restructure the SQL query to ensure that the counter only counts the rows with distinct product id's from the join?
Re: Pagination issues
Posted: Mon Jun 07, 2010 11:34 am
by Qphoria
You are using v1.4.7 ?
Re: Pagination issues
Posted: Mon Jun 07, 2010 6:42 pm
by OC2PS
Qphoria wrote:You are using v1.4.7 ?
1.2.9, I probably.
The SQL query in function getTotalProductsByCategoryId in /shop/catalog/model/catalog/product.php is (as also noted above) :
Code: Select all
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "product_to_category p2c LEFT JOIN " . DB_PREFIX . "product p ON (p2c.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "stock_status ss ON (p.stock_status_id = ss.stock_status_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2c.category_id = '" . (int)$category_id . "'");
return $query->row['total'];
Re: Pagination issues
Posted: Mon Jun 07, 2010 9:48 pm
by Qphoria
Ohh.. pfft.. this has been answered to death then. yea it was a bug years ago. Time to upgrade i guess
Re: Pagination issues
Posted: Tue Jun 08, 2010 6:21 pm
by OC2PS
Sorry if it has been answered before.
Before posting my question, I searched for pagination issues on the board...found some messages from Jan 09, but none relating to this specific problem.
Please can you point me to a relevant thread discussing the fix? Many thanks
Since I have many customizations, and since this is peak season for me, I can't upgrade yet. Will upgrade in low season (season), but need to fix this problem for now.
Re: Pagination issues
Posted: Sat Jun 12, 2010 7:45 am
by OC2PS
In the SQL statement, I changed the
to