Post by chongshengdz » Tue Sep 25, 2018 4:34 am

how to get the number of total products found on product search results?
for example: Showing 1 to 15 of 22 (2 Pages)
get the number 22

New member

Posts

Joined
Sat Apr 12, 2014 10:18 pm

Post by straightlight » Tue Sep 25, 2018 5:28 am

In OC v3.1.0.0, the system/library/pagination.php file will be abolished as it will be handled by a controller file instead. However, here's a tweak since the new version is still alpha:

Find:

Code: Select all

public $total = 0;
add below:

Code: Select all

public $end = 0;
Then, find:

Code: Select all

for ($i = $start; $i <= $end; $i++) {
add above:

Code: Select all

if (isset($end)) {
				$this->end = $end;
			}
Then, from your controller, you could use:

Code: Select all

$data['pagination_end'] = $pagination->end;
Finally, in your TWIG file, you could use:

Code: Select all

{% if pagination_end %}
{{ pagination_end }}
{% endif %}
This should resolved the issue.

The most generated errors being found on Opencart forum originates from contributed programming. The increased counters are caused by posted redundancies of the same solutions that were already provided prior.

F. Rules:

- viewtopic.php?f=176&t=200480
- viewtopic.php?f=176&t=200804


Regards,
Straightlight


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by chongshengdz » Wed Sep 26, 2018 1:45 am

thanks for your reply.
but it only shows the number of total pages.
i need to get the number of total products.
can you help again?

New member

Posts

Joined
Sat Apr 12, 2014 10:18 pm

Post by chongshengdz » Wed Sep 26, 2018 1:56 am

i change from

Code: Select all

$data['pagination_end'] = $pagination->end;
to

Code: Select all

$data['pagination_end'] = $pagination->total;
and it works perfect, many thanks for your help @straightlight

and there is no need to change php code in system/library/pagination.php
in template, just add {{ pagination_end }} anywhere if you like.

New member

Posts

Joined
Sat Apr 12, 2014 10:18 pm
Who is online

Users browsing this forum: No registered users and 11 guests