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

Electronic Components: integrated circuits, ic, semiconductors, transistors, thyristors, fuses, resistors, diodes, capacitors & more.
buy & sell transistors & mosfet


Active 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.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


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?

Electronic Components: integrated circuits, ic, semiconductors, transistors, thyristors, fuses, resistors, diodes, capacitors & more.
buy & sell transistors & mosfet


Active 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.

Electronic Components: integrated circuits, ic, semiconductors, transistors, thyristors, fuses, resistors, diodes, capacitors & more.
buy & sell transistors & mosfet


Active Member

Posts

Joined
Sat Apr 12, 2014 10:18 pm


Post by coldnsky » Thu Mar 24, 2022 3:45 am

straightlight wrote:
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.
Which controller is mentioned here below?
- Then, from your controller, you could use:

Code: Select all

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

Newbie

Posts

Joined
Wed Mar 23, 2022 10:41 pm

Post by straightlight » Fri Mar 25, 2022 8:33 pm

coldnsky wrote:
Thu Mar 24, 2022 3:45 am
straightlight wrote:
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.
Which controller is mentioned here below?
- Then, from your controller, you could use:

Code: Select all

$data['pagination_end'] = $pagination->end;
You could take a look at the master branch on the Github Opencart repository: admin/controller/common/pagination.php and catalog/controller/common/pagination.php file.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

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

Users browsing this forum: JessiesBoutique and 518 guests