MichaelEZ Posted February 18, 2020 Posted February 18, 2020 Hi, im looking for a way to display all manufacurers on one page, well i tried edit (default) ManufacturerController.php but got only error, or blank page, or nothing changed.
Traumflug Posted February 18, 2020 Posted February 18, 2020 What's wrong with https://<your site>/en/manufacturers? Should work without any edit.
MichaelEZ Posted February 18, 2020 Author Posted February 18, 2020 well it displays only 28 (as 28 is set as product per page), and i woud love to have all manufacturers on one page. Right now it looks like this : and what i want to achiev is this (display all manufacturers automatically) :
zen Posted February 18, 2020 Posted February 18, 2020 (edited) For that you can do an override in your shop, create a new file named : /override/classes/controller/FrontController.php and put that code inside : <?php /** * Class FrontControllerCore. * * adding a fix high number for manufacturer pagination so all brands are shown in one page only */ class FrontController extends FrontControllerCore { public function pagination($totalProducts = null) { if (!static::$initialized) { $this->init(); } // Retrieve the default number of products per page and the other available selections $defaultProductsPerPage = max(1, (int) Configuration::get('PS_PRODUCTS_PER_PAGE')); switch ($this->php_self) { case 'manufacturer': $defaultProductsPerPage=999; // this is the fixed high number for manufacturers per page. break; } $nArray = [$defaultProductsPerPage, $defaultProductsPerPage * 2, $defaultProductsPerPage * 5]; if ((int) Tools::getValue('n') && (int) $totalProducts > 0) { $nArray[] = $totalProducts; } // Retrieve the current number of products per page (either the default, the GET parameter or the one in the cookie) $this->n = $defaultProductsPerPage; if (isset($this->context->cookie->nb_item_per_page) && in_array($this->context->cookie->nb_item_per_page, $nArray)) { $this->n = (int) $this->context->cookie->nb_item_per_page; } if ((int) Tools::getValue('n') && in_array((int) Tools::getValue('n'), $nArray)) { $this->n = (int) Tools::getValue('n'); } // Retrieve the page number (either the GET parameter or the first page) $this->p = (int) Tools::getValue('p', 1); // If the parameter is not correct then redirect (do not merge with the previous line, the redirect is required in order to avoid duplicate content) if (!is_numeric($this->p) || $this->p < 1) { Tools::redirect($this->context->link->getPaginationLink(false, false, $this->n, false, 1, false)); } // Remove the page parameter in order to get a clean URL for the pagination template $currentUrl = preg_replace('/(?:(\?)|&)p=\d+/', '$1', Tools::htmlentitiesUTF8($_SERVER['REQUEST_URI'])); if ($this->n != $defaultProductsPerPage || isset($this->context->cookie->nb_item_per_page)) { $this->context->cookie->nb_item_per_page = $this->n; } $pagesNb = ceil($totalProducts / (int) $this->n); if ($this->p > $pagesNb && $totalProducts != 0) { Tools::redirect($this->context->link->getPaginationLink(false, false, $this->n, false, $pagesNb, false)); } $range = 2; /* how many pages around page selected */ $start = (int) ($this->p - $range); if ($start < 1) { $start = 1; } $stop = (int) ($this->p + $range); if ($stop > $pagesNb) { $stop = (int) $pagesNb; } $this->context->smarty->assign( [ 'nb_products' => $totalProducts, 'products_per_page' => $this->n, 'pages_nb' => $pagesNb, 'p' => $this->p, 'n' => $this->n, 'nArray' => $nArray, 'range' => $range, 'start' => $start, 'stop' => $stop, 'current_url' => $currentUrl, ] ); } } don't forget to delete this file after : cache/class_index.php and please verify that in your BO the overrides are not desactived. Enjoy 🙂 Edited February 18, 2020 by zen 1
MichaelEZ Posted February 19, 2020 Author Posted February 19, 2020 Once again i cant thank you enough! 😉 1
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