Missing Pagination for Product Bundles on Product Pages

Summary

The getBundles() service method in ProductBundleService fully supports pagination (page, items_per_page, get_total, total_items), and the admin bundle management page (product_bundles.manage) correctly implements it. However, two other pages that display bundles do not implement pagination at all, causing bundles beyond the limit to be silently hidden.


1. Admin Product Edit Page (dispatch=products.update)

Controller: app/addons/product_bundles/controllers/backend/products.post.php

  • Line 38: getBundles() is called without page, get_total, or explicit items_per_page
  • Defaults to admin_elements_per_page (typically 10)
  • The returned $params (containing total_items) is discarded: list($bundles,) = $service->getBundles($params);

Template: design/backend/templates/addons/product_bundles/hooks/products/tabs_extra.post.tpl

  • Simple {foreach $bundles as $bundle} loop (line 31)
  • No {include file="common/pagination.tpl"} — compare with views/product_bundles/manage.tpl which correctly includes it at lines 12 and 99

Result: If a product has 25 bundles and admin_elements_per_page = 10, only 10 are shown. No indication that 15 more exist. No way to navigate to them without going to the separate bundle management page.


2. Storefront Product View (dispatch=products.view)

Component: app/addons/product_bundles/src/SmartyPlugins/components/product_bundles/component.product_bundles.php

  • Lines 34-37: items_per_page is not set, so it defaults to admin_elements_per_page:
$bundles_params = [
    'full_info'      => true,
    'status'         => ObjectStatuses::ACTIVE,
];
  • No 'get_total' => true — total count never calculated
  • No 'page' => $_REQUEST['page'] — always loads page 1
  • Line 87: list($bundles,) = $bundle_service->getBundles($bundles_params); — pagination metadata discarded

Template: design/themes/responsive/templates/addons/product_bundles/components/common/product_bundles.tpl

  • Lines 35-40: Simple foreach with no pagination UI

Result: Storefront silently truncates bundles at the default admin_elements_per_page limit. Customers cannot see or access additional bundles. No “load more” or page navigation.


3. Correct Implementation for Reference (product_bundles.manage)

Controller: app/addons/product_bundles/controllers/backend/product_bundles.php (lines 131-156)

$params = [
    'page'           => 1,
    'items_per_page' => Registry::get('settings.Appearance.admin_elements_per_page'),
    'get_total'      => true,
];
$params = array_merge($params, $_REQUEST);
list($bundles, $search) = $bundle_service->getBundles($params);
$valid_page = db_get_valid_page($search['page'], $search['items_per_page'], $search['total_items']);

Template: design/backend/templates/addons/product_bundles/views/product_bundles/manage.tpl

{include file="common/pagination.tpl"}

This page works correctly. The other two pages should follow the same pattern.


Root Cause

The service layer (ProductBundleService::getBundles()) has full pagination support. The issue is that the callers (product edit controller, storefront component) don’t pass pagination parameters and don’t render pagination controls.

Area page get_total items_per_page Pagination UI Status
product_bundles.manage From $_REQUEST true From settings pagination.tpl OK
products.update tab Not passed Not passed Default (10) None BUG
products.view storefront Not passed Not passed Default (10) None BUG

Recommended Fix

Admin product edit (products.post.php):

  • Pass 'page', 'items_per_page', 'get_total' => true to getBundles()
  • Capture pagination data: list($bundles, $search) = ...
  • Pass $search to template for pagination rendering

Admin template (tabs_extra.post.tpl):

  • Add {include file="common/pagination.tpl"} before and after the bundles list

Storefront component (component.product_bundles.php):

  • Add 'get_total' => true and 'page' handling
  • Pass pagination data to template

Storefront template (product_bundles.tpl):

  • Add pagination or “load more” controls

Steps to Reproduce

  1. Create a product with 15+ bundles linked to it (via show_on_product_page = Y)
  2. Go to admin > Products > edit product > “Product Bundles” tab
  3. Observe: only first 10 bundles shown, no pagination, no indication more exist
  4. Go to storefront > view the same product
  5. Observe: only first 10 bundles shown, no pagination

Expected: All bundles accessible via pagination controls
Actual: Bundles beyond limit silently hidden

Also please increase name and storefront_name from varchar(50) to varchar(100) in bundles.