Jump to content

Configurer un lien avec un nombre de produits à afficher


toto__

Recommended Posts

Hi,

Je suis entrain d'essayer de créer un sélecteur de nombre de produits par page dans les catégories que j'ai trouvé ici  https://stackoverflow.com/questions/46500861/prestashop-1-7-products-per-page-dropdown-list-in-category 

First, create an override for classes/controller/ProductListingFrontController.php

and change line 279:

$resultsPerPage <= 0 || $resultsPerPage > 36

to (for example..)

$resultsPerPage <= 0 || $resultsPerPage > 100

100 in this example is the max number of items you want per page. You can also choose more or less, depending what you want. Now let's alter your .tpl

In your theme, go to themes/yourtheme/templates/catalog/_partials/sort-orders.tpl

On the top of the page (right underneath the licence) add this to assign the variables:

{if !empty($smarty.get.order)}
        {capture assign='ordering'}order={$smarty.get.order}&amp;{/capture}
    {else}
        {assign var='ordering' value=''}
    {/if}

    {if !empty($smarty.get.resultsPerPage)}
        {assign var='results_per_page' value=$smarty.get.resultsPerPage}
    {else}
        {assign var='results_per_page' value=25}
    {/if}

And now, right underneath, add this code:

<div class="col-md-3">
  <label style="float:left;margin-right: 15px" class="form-control-label hidden-sm-down sort-label">{l s='Products per page:'}</label>
  <div style="float:left;" class="sort-select dropdown js-dropdown">
    <a class="custom-select select-title" rel="nofollow" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
        {$results_per_page}
    </a>
    <div class="dropdown-menu">
      <a rel="nofollow" href="?{$ordering}resultsPerPage=25" class="dropdown-item js-search-link">
            25
        </a>
      <a rel="nofollow" href="?{$ordering}resultsPerPage=50" class="dropdown-item js-search-link">
            50
        </a>
      <a rel="nofollow" href="?{$ordering}resultsPerPage=75" class="dropdown-item js-search-link">
            75
        </a>
      <a rel="nofollow" href="?{$ordering}resultsPerPage=100" class="dropdown-item js-search-link">
            100
        </a>
    </div>
  </div>
</div>

Maintenant, je souhaite avoir un lien dynamique qui marche pour les cas suivants ==> <a rel="nofollow" href="?{$ordering}resultsPerPage=25">

-Recherche dans le site: recherche?controller=search&order=product.name.desc&s=exemple&resultsPerPage=100 au lieu de recherche?resultsPerPage=100

-Affichage uniquement: ?resultsPerPage=100

-Tri et affichage ?order=product.name.desc&resultsPerPage=100

-Filtre: s-1/marque_2-adidas+nike+jomùa?order=product.position.desc&resultsPerPage=100

 

Merci.

 

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...