Post by OC2PS » Sun Jun 06, 2010 3:08 pm

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:

Code: Select all

Showing 1 to 12 of 22 (2 Pages)
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!

Attachments

Capture.JPG

Capture.JPG (66.79 KiB) Viewed 5915 times


OC2PS
OC 3.0.3.7, vQmod 2.6.2, Journal3 theme
Arcfesték, Csillámtetoválás, Henna
Image
Check out: All my extensions | My FREE extensions


User avatar
Active Member

Posts

Joined
Wed Jul 22, 2009 4:15 am
Location - Hungary

Post by pstechnee » Sun Jun 06, 2010 4:56 pm

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

Shriman TechnologiesImage


Newbie

Posts

Joined
Wed Aug 26, 2009 10:39 pm

Post by OC2PS » Sun Jun 06, 2010 5:21 pm

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.

OC2PS
OC 3.0.3.7, vQmod 2.6.2, Journal3 theme
Arcfesték, Csillámtetoválás, Henna
Image
Check out: All my extensions | My FREE extensions


User avatar
Active Member

Posts

Joined
Wed Jul 22, 2009 4:15 am
Location - Hungary

Post by pstechnee » Sun Jun 06, 2010 5:40 pm

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.

Shriman TechnologiesImage


Newbie

Posts

Joined
Wed Aug 26, 2009 10:39 pm

Post by OC2PS » Sun Jun 06, 2010 6:16 pm

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

OC2PS
OC 3.0.3.7, vQmod 2.6.2, Journal3 theme
Arcfesték, Csillámtetoválás, Henna
Image
Check out: All my extensions | My FREE extensions


User avatar
Active Member

Posts

Joined
Wed Jul 22, 2009 4:15 am
Location - Hungary

Post by OC2PS » Sun Jun 06, 2010 6:20 pm

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

OC2PS
OC 3.0.3.7, vQmod 2.6.2, Journal3 theme
Arcfesték, Csillámtetoválás, Henna
Image
Check out: All my extensions | My FREE extensions


User avatar
Active Member

Posts

Joined
Wed Jul 22, 2009 4:15 am
Location - Hungary

Post by OC2PS » Sun Jun 06, 2010 6:23 pm

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'];

OC2PS
OC 3.0.3.7, vQmod 2.6.2, Journal3 theme
Arcfesték, Csillámtetoválás, Henna
Image
Check out: All my extensions | My FREE extensions


User avatar
Active Member

Posts

Joined
Wed Jul 22, 2009 4:15 am
Location - Hungary

Post by Qphoria » Sun Jun 06, 2010 11:22 pm

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.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by OC2PS » Mon Jun 07, 2010 2:14 am

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

OC2PS
OC 3.0.3.7, vQmod 2.6.2, Journal3 theme
Arcfesték, Csillámtetoválás, Henna
Image
Check out: All my extensions | My FREE extensions


User avatar
Active Member

Posts

Joined
Wed Jul 22, 2009 4:15 am
Location - Hungary

Post by jefrey1983 » Mon Jun 07, 2010 3:58 am

happens to me i put 9 instead because when i put 8 it only shows 7 latest product

User avatar
Active Member

Posts

Joined
Sat Jan 30, 2010 6:58 pm

Post by OC2PS » Mon Jun 07, 2010 6:03 am

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?

OC2PS
OC 3.0.3.7, vQmod 2.6.2, Journal3 theme
Arcfesték, Csillámtetoválás, Henna
Image
Check out: All my extensions | My FREE extensions


User avatar
Active Member

Posts

Joined
Wed Jul 22, 2009 4:15 am
Location - Hungary

Post by Qphoria » Mon Jun 07, 2010 11:34 am

You are using v1.4.7 ?

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by OC2PS » Mon Jun 07, 2010 6:42 pm

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'];

OC2PS
OC 3.0.3.7, vQmod 2.6.2, Journal3 theme
Arcfesték, Csillámtetoválás, Henna
Image
Check out: All my extensions | My FREE extensions


User avatar
Active Member

Posts

Joined
Wed Jul 22, 2009 4:15 am
Location - Hungary

Post by Qphoria » Mon Jun 07, 2010 9:48 pm

Ohh.. pfft.. this has been answered to death then. yea it was a bug years ago. Time to upgrade i guess

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by OC2PS » Tue Jun 08, 2010 6:21 pm

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.

OC2PS
OC 3.0.3.7, vQmod 2.6.2, Journal3 theme
Arcfesték, Csillámtetoválás, Henna
Image
Check out: All my extensions | My FREE extensions


User avatar
Active Member

Posts

Joined
Wed Jul 22, 2009 4:15 am
Location - Hungary

Post by OC2PS » Sat Jun 12, 2010 7:45 am

In the SQL statement, I changed the

Code: Select all

COUNT(*)
to

Code: Select all

round(COUNT(*)/2)

OC2PS
OC 3.0.3.7, vQmod 2.6.2, Journal3 theme
Arcfesték, Csillámtetoválás, Henna
Image
Check out: All my extensions | My FREE extensions


User avatar
Active Member

Posts

Joined
Wed Jul 22, 2009 4:15 am
Location - Hungary
Who is online

Users browsing this forum: Semrush [Bot] and 28 guests