Jluis Posted November 17, 2020 Share Posted November 17, 2020 (edited) Hello , in order to show a max number of page for pagination , i modified the function for pagination class : src/Core/Product/Search/Pagination.php as below : public function buildLinks() { $links = []; $addPageLink = function ($page) use (&$links) { static $lastPage = null; if ($page < 1 || $page > $this->getPagesCount()) { return; } if (null !== $lastPage && $page > $lastPage + 1) { $links[] = $this->buildSpacer(); } if ($page !== $lastPage) { $links[] = $this->buildPageLink($page); } $lastPage = $page; }; $boundaryContextLength = 1; /** Modifcation ***/ //By default it is 3 $pageContextLength = 14; $links[] = $this->buildPageLink(max(1, $this->getPage() - 1), 'previous'); for ($i = 0; $i < $boundaryContextLength; ++$i) { $addPageLink(1 + $i); } $start = max(1, $this->getPage() - (int) floor(($pageContextLength - 1) / 2)); if ($start + $pageContextLength > $this->getPagesCount()) { $start = $this->getPagesCount() - $pageContextLength + 1; } for ($i = 0; $i < $pageContextLength; ++$i) { $addPageLink($start + $i); } for ($i = 0; $i < $boundaryContextLength; ++$i) { $addPageLink($this->getPagesCount() - $boundaryContextLength + 1 + $i); } $links[] = $this->buildPageLink(min($this->getPagesCount(), $this->getPage() + 1), 'next'); return $links; } what is the best way to override that function ? by a module either simple override ? Edited November 17, 2020 by Jluis (see edit history) Link to comment Share on other sites More sharing options...
Verlonimo Posted November 17, 2020 Share Posted November 17, 2020 Hi, 1. From UX side. Why would you want to display such long pagination? User usually use 1.2.3 and so on... no one gonna go to page 10 and start there... Have you thought about mobile users? How its gonna display? Cause its about 60-80% of your customers if not more... 2. As far as i know you cant override files in src folder on 1.7 version. Thanks Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now