Jump to content

Pagination does not work after upgrade to 6.5.0


Claudia

Recommended Posts

Your question implies you are viewing a page of items in a category. Fetching a list of products in a category list uses the function, searchCatalogue(), but does not interfere with the $page number that a regular search does. (See issue #3066 in the Github.)

Please enable CubeCart's debug mode. (The Foundation skin as of CC650+ now shows the debug panel as a popup. (And, if using Firefox, you need to close the popup in order to see the popup of the next page. Otherwise, the next page of debug data has been added to the bottom of the existing content, but the popup might not scroll to that new data.)

Make sure that, GET: "After Sanitation", there are 'cat_id' and a 'page' keys. Further down, look for a SQL statement that looks like:

Probably close to query #22:
SELECT * FROM `CubeCart_inventory` WHERE (`product_id` IN (2,19,20,21)) AND CubeCart_inventory.status = '1' ORDER BY `updated` ASC LIMIT 12 OFFSET 12;

-- where OFFSET 12 is a multiple of 12,
-- and (2,19,20,21) is a coma separated 
   list of products belonging to this category.

As for the list of product_ids, how many values are in your list?

Edited by bsmither
Link to comment
Share on other sites

GET:

'Before Sanitise:' =>
'seo_path' => ashtrays
'page' => 2
'After Sanitise:' =>
'_a' => category
'cat_id' => 3
'page' => 2

 

This is the only thing I closely resembling query

31. Hack: 1681070244.17480 --- Duration: 7838 µs [CACHE WRITE] --- Key: sql.42a84a6e1af5e736143e4cb797ab58da
SELECT * FROM `CubeCart_inventory` WHERE `product_id` IN (80,100,79,103,113,115,124,7,116,29,104,106,108,109,110,112,27,28,26,111,78,75,14,8,15,9,122,119,65,66,64,67,121,126) AND CubeCart_inventory.status = '1' ORDER BY `excel_name` ASC LIMIT 12 OFFSET 0;
32.

Hack: 1681070244.17700 --- Duration: 1999 µs [CACHE WRITE] --- Key: sql.f5558282f2540e546ea7a9f62bb3fbc4
SELECT COUNT(*) AS `Count` FROM `CubeCart_inventory` WHERE `product_id` IN (80,100,79,103,113,115,124,7,116,29,104,106,108,109,110,112,27,28,26,111,78,75,14,8,15,9,122,119,65,66,64,67,121,126) AND CubeCart_inventory.status = '1' ;

 

As for the list of product_ids, how many values are in your list?

Where do I find this?

All above is if I'm on page 2 of ashtrays

Here's what I have on view all page

23. Hack: 1681071325.20270 --- Duration: 424 µs [CACHE READ] --- Key: sql.42a84a6e1af5e736143e4cb797ab58da
SELECT * FROM `CubeCart_inventory` WHERE `product_id` IN (80,100,79,103,113,115,124,7,116,29,104,106,108,109,110,112,27,28,26,111,78,75,14,8,15,9,122,119,65,66,64,67,121,126) AND CubeCart_inventory.status = '1' ORDER BY `excel_name` ASC LIMIT 12 OFFSET 0;
Link to comment
Share on other sites

Being on page 2, it is the OFFSET 0 that I do not like.

In /classes/catalogue.class.php, near lines 1820-1825, verify that these lines exist as follows:

        if (strtolower($page) != 'all') {
            $page = (is_numeric($page)) ? $page : 1;
            $limit = sprintf('LIMIT %d OFFSET %d', (int)$per_page, $per_page*($page-1));
        } else {
            $limit = 'LIMIT 100';
        }

When page=all, I expect the LIMIT to be 100 and no OFFSET.

--- Scratch all the above. ---

Looking elsewhere.

Edited by bsmither
Link to comment
Share on other sites

I have it at line 1845

 $sale_mode = $GLOBALS['config']->get('config', 'catalogue_sale_mode');

            if ($sale_mode == 2) {
                $sale_percentage = $GLOBALS['config']->get('config', 'catalogue_sale_percentage');
            }
            $user = (array)$GLOBALS['user']->get();
            $group_id = 'WHERE group_id = 0';
            if (($memberships = $GLOBALS['user']->getMemberships()) !== false) {
                $group_id = 'WHERE ';
                foreach ($memberships as $membership) {
                    $group_id .= 'group_id = '.$membership['group_id'].' OR ';
                }
                $group_id = substr($group_id, 0, -4);
            }

            if (strtolower($page) != 'all') {
                $page = (is_numeric($page)) ? $page : 1;
                $limit = sprintf('LIMIT %d OFFSET %d', (int)$per_page, $per_page*($page-1));
            } else {
                $limit = 'LIMIT 100';
            }

            
            // Presence of a join is similar to presence of a search keyword
            if (!empty($joins) || is_array($search_data)) {
                if($GLOBALS['config']->get('config', 'hide_out_of_stock')=='1') {
                    $search_data['inStock'] = true;
                }

Link to comment
Share on other sites

$GLOBALS['debug']->debugMessage('At '.__METHOD__.', line ('.__LINE__.'), $page is '.$page.' and $per_page is '.$per_page);

In catalogue.class.php, near line 2110-2111, find:
            if (is_numeric($search_data)) {
                if (($category = $this->getCategoryData((int)$search_data)) !== false) {

Add the debug statement immediately after the end of the SECOND statement above.

In catalogue.class.php, near lines 798-800, find:
            foreach ($GLOBALS['hooks']->load('class.catalogue.category_product_list') as $hook) {
                include $hook;
            }

Add the debug statement immediately after the end of the THIRD statement above.

In catalogue.class.php, near lines 1106-1110, find:
        } else {
            $result = $GLOBALS['db']->select('CubeCart_inventory', false, $where, $order, $per_page, $page);
        }

        // Get product option specific data

Add the debug statement immediately after the end of the FIRST statement above.

At the bottom of the debug section (popup?) will be a set of Debug Messages.

Link to comment
Share on other sites

Is this what you are looking for?

[0] At Catalogue::searchCatalogue, line (2114), $page is 1 and $per_page is 48
[1] At Catalogue::getCategoryProducts, line (801), $page is 1 and $per_page is 48
[2] At Catalogue::getProductData, line (1112), $page is 1 and $per_page is 48

I changed the products per page from 12 to 48 in skin config and admin to show more products

Link to comment
Share on other sites

Yes (line numbers are close enough to my experiments).

This is page=1? Have you tried page=2?

And $per_page is 48??? The query is using LIMIT 12.

This suggests the fault is happening earlier in searchCatalogue(), or even before getting there.

Gotta go for now.

 

 

Link to comment
Share on other sites

I do not think so. (But we can explore this later.)

In /classes/cubecart.class.php:

Find near line 880-882:
$page = (isset($_REQUEST['page']) && !empty($_REQUEST['page'])) ? $_REQUEST['page'] : 1;

$catalogue_products_per_page = $GLOBALS['gui']->itemsPerPage();

After these lines, add:
$GLOBALS['debug']->debugMessage('At '.__METHOD__.', line ('.__LINE__.'), $page is '.$page.' and $catalogue_products_per_page is '.$catalogue_products_per_page);

This is looking at code that executes just one step ahead of the searchCatalogue() function. If the $page number does change to 2, then we've narrowed where the problem exists.

I see above that you mentioned you changed the skin config.xml file to default the number per page to 48.

 

Link to comment
Share on other sites

This is what I get:

[0] At Cubecart::_category, line (883), $page is 1 and $catalogue_products_per_page is 48
[1] At Catalogue::searchCatalogue, line (2114), $page is 1 and $per_page is 48
[2] At Catalogue::getCategoryProducts, line (801), $page is 1 and $per_page is 48
[3] At Catalogue::getProductData, line (1112), $page is 1 and $per_page is 48

I changed the amount per page to 48 because people couldn't see items after the first page of 12 if there are more that 12 items in that category

Link to comment
Share on other sites

Looking at the first page of aromatherapy:

GET:

'Before Sanitise:' =>
'seo_path' => aromatherapy
'After Sanitise:' =>
'_a' => category
'cat_id' => 55
 
Debug Messages:
[0] At Cubecart::_category, line (883), $page is 1 and $catalogue_products_per_page is 48
[1] At Catalogue::searchCatalogue, line (2114), $page is 1 and $per_page is 48
[2] At Catalogue::getCategoryProducts, line (801), $page is 1 and $per_page is 48
[3] At Catalogue::getProductData, line (1112), $page is 1 and $per_page is 48
 
Looking at the second page of aromatherapy:
GET:
'Before Sanitise:' =>
'seo_path' => aromatherapy
'page' => 2
'After Sanitise:' =>
'_a' => category
'cat_id' => 55
'page' => 2
 
Debug Messages:
[0] At Cubecart::_category, line (883), $page is 2 and $catalogue_products_per_page is 48
[1] At Catalogue::searchCatalogue, line (2114), $page is 1 and $per_page is 48
[2] At Catalogue::getCategoryProducts, line (801), $page is 1 and $per_page is 48
[3] At Catalogue::getProductData, line (1112), $page is 1 and $per_page is 48
 
Looking at the view all page of aromatherapy:
GET:
'Before Sanitise:' =>
'seo_path' => aromatherapy
'page' => all
'After Sanitise:' =>
'_a' => category
'cat_id' => 55
'page' => all
 
Debug Messages:
[0] At Cubecart::_category, line (883), $page is all and $catalogue_products_per_page is 48
[1] At Catalogue::searchCatalogue, line (2114), $page is 1 and $per_page is 48
[2] At Catalogue::getCategoryProducts, line (801), $page is 1 and $per_page is 48
[3] At Catalogue::getProductData, line (1112), $page is 1 and $per_page is 48
 
Link to comment
Share on other sites

Good. Somewhere between [0] and [1] that $page is getting damaged.

In /classes/catalogue.class.php:

Use this debug statement:
$GLOBALS['debug']->debugMessage('At '.__METHOD__.', line ('.__LINE__.'), $page is '.$page.' and $per_page is '.$per_page);

Near lines 1783-1785, find:
    public function searchCatalogue($search_data = null, $page = 1, $per_page = 10, $search_mode = 'elastic')
    {
        $per_page = (!is_numeric($per_page) || $per_page < 1) ? 10 : $per_page;

Add the debug statement after the end of the THIRD line.

Near lines 1820-1825, find:
        if (strtolower($page) != 'all') {
            $page = (is_numeric($page)) ? $page : 1;
            $limit = sprintf('LIMIT %d OFFSET %d', (int)$per_page, $per_page*($page-1));
        } else {
            $limit = 'LIMIT 100';
        }

Add the debug statement after the end of the SIXTH line.

In /classes/cubecart.class.php:

Near line 890-893, make sure the statements are as follows:
            $GLOBALS['gui']->addBreadcrumb($GLOBALS['language']->common['search'], 'index.php?_a=search');
            $GLOBALS['gui']->addBreadcrumb($GLOBALS['language']->navigation['search_results'], currentPage());
        } else {
            $GLOBALS['catalogue']->searchCatalogue($_GET['cat_id'], $page, $catalogue_products_per_page);

 

Link to comment
Share on other sites

code in cubecart class is the same

Aromatherapy First Page

GET:

'Before Sanitise:' =>
'seo_path' => aromatherapy
'After Sanitise:' =>
'_a' => category
'cat_id' => 55
 
Debug Messages:
[0] At Cubecart::_category, line (883), $page is 1 and $catalogue_products_per_page is 48
[1] At Catalogue::searchCatalogue, line (2121), $page is 1 and $per_page is 48
[2] At Catalogue::getCategoryProducts, line (801), $page is 1 and $per_page is 48
[3] At Catalogue::getProductData, line (1112), $page is 1 and $per_page is 48
 
Page 2
GET:
'Before Sanitise:' =>
'seo_path' => aromatherapy
'page' => 2
'After Sanitise:' =>
'_a' => category
'cat_id' => 55
'page' => 2
 
Debug Messages:
[0] At Cubecart::_category, line (883), $page is 2 and $catalogue_products_per_page is 48
[1] At Catalogue::searchCatalogue, line (2121), $page is 1 and $per_page is 48
[2] At Catalogue::getCategoryProducts, line (801), $page is 1 and $per_page is 48
[3] At Catalogue::getProductData, line (1112), $page is 1 and $per_page is 48
 
View All
GET:
'Before Sanitise:' =>
'seo_path' => aromatherapy
'page' => all
'After Sanitise:' =>
'_a' => category
'cat_id' => 55
'page' => all
 
Debug Messages:
[0] At Cubecart::_category, line (883), $page is all and $catalogue_products_per_page is 48
[1] At Catalogue::searchCatalogue, line (2121), $page is 1 and $per_page is 48
[2] At Catalogue::getCategoryProducts, line (801), $page is 1 and $per_page is 48
[3] At Catalogue::getProductData, line (1112), $page is 1 and $per_page is 48

Forget the above.  The debug code didn't take

Forget the above.  The debug code didn't take

View all:


GET:

'Before Sanitise:' =>
'seo_path' => aromatherapy
'page' => all
'After Sanitise:' =>
'_a' => category
'cat_id' => 55
'page' => all
 
[0] At Cubecart::_category, line (883), $page is all and $catalogue_products_per_page is 48
[1] At Catalogue::searchCatalogue, line (1788), $page is all and $per_page is 48
[2] At Catalogue::searchCatalogue, line (1796), $page is all and $per_page is 48
[3] At Catalogue::searchCatalogue, line (1788), $page is 1 and $per_page is 48
[4] At Catalogue::searchCatalogue, line (1796), $page is 1 and $per_page is 48
[5] At Catalogue::searchCatalogue, line (2122), $page is 1 and $per_page is 48
[6] At Catalogue::getCategoryProducts, line (801), $page is 1 and $per_page is 48
[7] At Catalogue::getProductData, line (1112), $page is 1 and $per_page is 48
 
First Page
GET:
'Before Sanitise:' =>
'seo_path' => aromatherapy
'After Sanitise:' =>
'_a' => category
'cat_id' => 55
 
Debug Messages:
[0] At Cubecart::_category, line (883), $page is 1 and $catalogue_products_per_page is 48
[1] At Catalogue::searchCatalogue, line (1788), $page is 1 and $per_page is 48
[2] At Catalogue::searchCatalogue, line (1796), $page is 1 and $per_page is 48
[3] At Catalogue::searchCatalogue, line (1788), $page is 1 and $per_page is 48
[4] At Catalogue::searchCatalogue, line (1796), $page is 1 and $per_page is 48
[5] At Catalogue::searchCatalogue, line (2122), $page is 1 and $per_page is 48
[6] At Catalogue::getCategoryProducts, line (801), $page is 1 and $per_page is 48
[7] At Catalogue::getProductData, line (1112), $page is 1 and $per_page is 48
 
Second Page
GET:
'Before Sanitise:' =>
'seo_path' => aromatherapy
'page' => 2
'After Sanitise:' =>
'_a' => category
'cat_id' => 55
'page' => 2
 
Debug Messages:
[0] At Cubecart::_category, line (883), $page is 2 and $catalogue_products_per_page is 48
[1] At Catalogue::searchCatalogue, line (1788), $page is 2 and $per_page is 48
[2] At Catalogue::searchCatalogue, line (1796), $page is 2 and $per_page is 48
[3] At Catalogue::searchCatalogue, line (1788), $page is 1 and $per_page is 48
[4] At Catalogue::searchCatalogue, line (1796), $page is 1 and $per_page is 48
[5] At Catalogue::searchCatalogue, line (2122), $page is 1 and $per_page is 48
[6] At Catalogue::getCategoryProducts, line (801), $page is 1 and $per_page is 48
[7] At Catalogue::getProductData, line (1112), $page is 1 and $per_page is 48
 
 
Link to comment
Share on other sites

Did you retry the test having fixed the "debug code didn't take" at near lines 1783 and 1820?

Oh, I see. You added more content.

Show me a few lines of code above and below Catalogue::searchCatalogue, line (1796).

The list shows that after line 1796, execution somehow gets sent back to line 1788.

 

Edited by bsmither
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...