Jump to content

"Show All" Feature on Page Does Not Work


Recommended Posts

On the product categories page. Prestashop 1.6 default theme has a button "show all" so that customers dont have to scroll through 25 pages. The problem is, when someone clicks this it just resets to the same page that it was on it doesnt not show all. 

 

Ive run this test on firefox, IE, and Safari. Is there a fix for this?

Link to comment
Share on other sites

default theme, pagination.tpl:

<form method="get" action="http://troikos.pt/25-last-kings" class="showall">
    <div>
        <button class="btn btn-default button exclusive-medium" type="submit">
                <span>Show all</span>
        </button>
        <input type="hidden" value="25" name="id_category">
        <input value="28" class="hidden" id="nb_item" name="n">
    </div>
</form>

after submit:

http://troikos.pt/25-last-kings?id_category=25&n=28

 

but still only 12 products showing

Edited by venereo (see edit history)
Link to comment
Share on other sites

It seems it's still using the value from the cookie and not respecting the n parameter passed....

 

maybe here? classes/controller/FrontController.php:

        // Retrieve the current number of products per page (either the default, the GET parameter or the one in the cookie)
        $this->n = $default_products_per_page;
        if ((int)Tools::getValue('n') > 0 && in_array((int)Tools::getValue('n'), $nArray))
            $this->n = (int)Tools::getValue('n');
        elseif (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;

edit:

$nArray = array($default_products_per_page, $default_products_per_page * 2, $default_products_per_page * 5);

$this->n being in $nArray is pure luck, so changing

if ((int)Tools::getValue('n') > 0 && in_array((int)Tools::getValue('n'), $nArray))

to

if ((int)Tools::getValue('n') > 0 || in_array((int)Tools::getValue('n'), $nArray))

fixes the problem, but i'm not sure if it's the perfect solution.

 

:)

Edited by venereo (see edit history)
Link to comment
Share on other sites

it's impossible to check website because it's under maintenance mode

 

check my above posts, the buggy line is this one from FrontController.php:

if ((int)Tools::getValue('n') > 0 && in_array((int)Tools::getValue('n'), $nArray))

https://github.com/PrestaShop/PrestaShop/blob/1.6/classes/controller/FrontController.php#L893

 

edit: at github it's already fixed

Edited by venereo (see edit history)
Link to comment
Share on other sites

edit: at github it's already fixed

 

This fix only works if you are on the initial category page.

If you navigate to page 2 for example and then select view all, it takes you to page 1 and does not showall :-(

 

Any other fixes out there?

Link to comment
Share on other sites

This fix only works if you are on the initial category page.

If you navigate to page 2 for example and then select view all, it takes you to page 1 and does not showall :-(

 

Any other fixes out there?

 

 

try my fix above

 

http://www.prestashop.com/forums/topic/327112-show-all-feature-on-page-does-not-work/?do=findComment&comment=1656144

Edited by venereo (see edit history)
Link to comment
Share on other sites

  • 4 weeks later...

I tried both fixes and neither work. Any other suggestions? My site is www.gitar.be/shop... Thanks!

 

EDIT: The code i have is:

// Retrieve the current number of products per page (either the default, the GET parameter or the one in the cookie)
		$this->n = $default_products_per_page;
		if ((int)Tools::getValue('n') > 0 && in_array((int)Tools::getValue('n'), $nArray))
			$this->n = (int)Tools::getValue('n');
		elseif (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;

I tried swapping it out but no change...

Edited by SandrGitar (see edit history)
Link to comment
Share on other sites

  • 4 weeks later...

Wow Thanks It fixed mine

 

Thanks alot, Any idea how to show lowest to highest default in the product list page?

 

Ash

 

 

check my above posts, the buggy line is this one from FrontController.php:

if ((int)Tools::getValue('n') > 0 && in_array((int)Tools::getValue('n'), $nArray))

https://github.com/PrestaShop/PrestaShop/blob/1.6/classes/controller/FrontController.php#L893

 

edit: at github it's already fixed

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...
 

I tried to make all the changes which are proposed in the thread, at first glance - the problem seems fixed.

 

But when I press show all button, return to homepage, and then return to the catalogue again, it says that as if 1-60 items are showing (and there is no show all button), but in fact it displays only 20.

 

Basically it is the same problem that ashadweb has.

 

Anyone has answers for this? 

 

Btw, I checked nathanielle website: www.ApostolicClothing.com

And it seems he somehow found a way to completely solve this SHOW ALL button problem..... >.<

Link to comment
Share on other sites

  • 2 weeks later...

None of that worked for me. The last one even does Show All always, with no option.

 

Here's my solution, which does work for me (commencing at was was line 893, before the GitHub changes noted above) ...

 

                // Retrieve the current number of products per page (either the default, the GET parameter or the one in the cookie)

                $this->n = $default_products_per_page;

                if ((int)Tools::getValue('n') > 0 || in_array((int)Tools::getValue('n'), $nArray))

                        $this->n = (int)Tools::getValue('n');

                elseif (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;

 

                else {

                        // 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(self::$link->getPaginationLink(false, false, $this->n, false, 1, false));

                }

 
(Sorry about the weird font and colors. I doesn't look horrid like this when I paste the code into the editor.)
 
This code is a combination of the first solution offered above (which works only on page 1) plus an extra else { ... } wrapper around "Retrieve page number" code, to prevent that happening at all if n is present, since p= seems to override n= in all cases otherwise.
 
This then, works from page 1 AND pages 2 ... last.
 
 
 
 
Link to comment
Share on other sites

  • 2 weeks later...
  • 4 weeks later...

Same problem. None of solutions works. When you click on page 2,3 ot other and then click SHOW ALL - it redirect you to 1 page. Also with layrered navigation block same problem, if you change any of filter - show all button not works. Please I need help.

 

PS version 1.6.0.9

All modules updated.

Edited by RoyVelvet (see edit history)
Link to comment
Share on other sites

Finally I found out solution for me. None of Frontcontroller or pagination.tpl modifications helps. Just don't touch it.

 

Only this link helped me. 

 

https://raw.githubusercontent.com/PrestaShop/PrestaShop/1a55226db119527092aa1132903fd66834abac6d/themes/default-bootstrap/js/modules/blocklayered/blocklayered.js

 

Just put it to yourshopsolder/themes/yourtheme/js/modules/blocklayered/blocklayered.js

 

Also update blocklayered module if you have old version.

 

Thats it! It solves problem with SHOW ALL button from 2,3, etc pages, also solves any problems with layered navigation block and pagination.

Link to comment
Share on other sites

  • 4 weeks later...

Finally I found out solution for me. None of Frontcontroller or pagination.tpl modifications helps. Just don't touch it.

 

Only this link helped me. 

 

https://raw.githubusercontent.com/PrestaShop/PrestaShop/1a55226db119527092aa1132903fd66834abac6d/themes/default-bootstrap/js/modules/blocklayered/blocklayered.js

 

Just put it to yourshopsolder/themes/yourtheme/js/modules/blocklayered/blocklayered.js

 

Also update blocklayered module if you have old version.

 

Thats it! It solves problem with SHOW ALL button from 2,3, etc pages, also solves any problems with layered navigation block and pagination.

 

Hi, thanks!!

 

What are the changes? I don't want to overwrite the file, I prefer to add/modify the changes directly.

 

Regards :)

Link to comment
Share on other sites

  • 2 months later...
×
×
  • Create New...