rozhawni Posted October 6, 2018 Share Posted October 6, 2018 (edited) Greetings! Before we start, my prestashop version is 1.7.4.0 and we use the ZOne Theme provided by Mr. ZOne. Now to the good part first, then the issue later on. in this file, public_html/themes/ZOneTheme/templates/catalog/_partials/sort-orders.tpl, Ive added the following code: {if !empty($smarty.get.order)} {capture assign='ordering'}order={$smarty.get.order}&a{/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=20} {/if} <div class="d-flex flex-wrap"> <label style="float:left;margin-right: 10px;" class="form-control-label d-none d-md-block sort-label">{l s='Products per page:'} </label> <div style="float:left;padding-left: 0px;" class="sort-select dropdown js-dropdown col-lg-3 col-md-3 col-sm-3"> <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=20" class="dropdown-item js-search-link"> 20 </a> <a rel="nofollow" href="?{$ordering}resultsPerPage=40" class="dropdown-item js-search-link"> 40 </a> <a rel="nofollow" href="?{$ordering}resultsPerPage=60" class="dropdown-item js-search-link"> 60 </a> <a rel="nofollow" href="?{$ordering}resultsPerPage=80" class="dropdown-item js-search-link"> 80 </a> <a rel="nofollow" href="?{$ordering}resultsPerPage=100" class="dropdown-item js-search-link"> 100 </a> </div> </div> </div> which gives a nice dropdown menu to set the amount of products per page in the category view. Now, changing the amount to 40 through the menu, it adds ?resultsPerPage=40 to the current URL which works flawlessly. example: https://www.insertdomainnamehere.com/1234-computers tohttps://www.insertdomainnamehere.com/1234-computers?resultsPerPage=40 so far, so good. showing the computers category with 40 products per page. if there is a filter going on already, like (Price, Low to High), the new url will behttps://www.insertdomainnamehere.com/1234-computers?aresultsPerPage=60&order=product.price.asc ***PS. I have no idea why sometimes that "a" is showing up right before resultsPerPage=60, but no worries, it still works*** Next, when I search for a product using the official/standard search module, in this case searching "Clothes", the url will be https://www.insertdomainnamehere.com/search?controller=search&s=clothes so far so good... But here comes the issue when the customer wishes to see 40 / 60 / 80 / 100 products per page in the search page. when clicking on any of them, example 40, the URL changes to https://www.insertdomainnamehere.com/search?resultsPerPage=40 instead ofhttps://www.insertdomainnamehere.com/search?controller=search&s=clothes&resultsPerPage=40 when I manually paste in &resultsPerPage=40 in the URL after the search result URL, it works perfectly. As mentioned above, when I click 40 in the dropdown menu, it sends me to https://www.insertdomainnamehere.com/search?resultsPerPage=40 which leads to no search result at all. "showing 1- of products" in stead of "showing 40 of ___ products Any ideas what could cause this issue? Edited October 6, 2018 by rozhawni (see edit history) Link to comment Share on other sites More sharing options...
Jorkoo Posted April 30, 2020 Share Posted April 30, 2020 You should change the "urls" of each anchor for choosing page count to include the search string. <div class="dropdown-menu"> <a rel="nofollow" href="?{$ordering}resultsPerPage=12&s={$search_string}" class="dropdown-item js-search-link"> 12 </a> <a rel="nofollow" href="?{$ordering}resultsPerPage=24&s={$search_string}" class="dropdown-item js-search-link"> 24 </a> <a rel="nofollow" href="?{$ordering}resultsPerPage=48&s={$search_string}" class="dropdown-item js-search-link"> 48 </a> <a rel="nofollow" href="?{$ordering}resultsPerPage=60&s={$search_string}" class="dropdown-item js-search-link"> 60 </a> <a rel="nofollow" href="?{$ordering}resultsPerPage=99&s={$search_string}" class="dropdown-item js-search-link"> 99 </a> </div> Link to comment Share on other sites More sharing options...
Jorkoo Posted April 30, 2020 Share Posted April 30, 2020 and about the letter "a" sometimes appearing in the url {capture assign='ordering'}order={$smarty.get.order}&a{/capture} remove the a {capture assign='ordering'}order={$smarty.get.order}&{/capture} Link to comment Share on other sites More sharing options...
sk3pt1c Posted May 4, 2020 Share Posted May 4, 2020 On 4/30/2020 at 2:10 PM, Jorkoo said: You should change the "urls" of each anchor for choosing page count to include the search string. <div class="dropdown-menu"> <a rel="nofollow" href="?{$ordering}resultsPerPage=12&s={$search_string}" class="dropdown-item js-search-link"> 12 </a> <a rel="nofollow" href="?{$ordering}resultsPerPage=24&s={$search_string}" class="dropdown-item js-search-link"> 24 </a> <a rel="nofollow" href="?{$ordering}resultsPerPage=48&s={$search_string}" class="dropdown-item js-search-link"> 48 </a> <a rel="nofollow" href="?{$ordering}resultsPerPage=60&s={$search_string}" class="dropdown-item js-search-link"> 60 </a> <a rel="nofollow" href="?{$ordering}resultsPerPage=99&s={$search_string}" class="dropdown-item js-search-link"> 99 </a> </div> Hi there, I have a similar issue, fixed it with your tip but now it also breaks where there is a filter from the left column, the url is /40-books?q=filter&resultsPerPage=16 for instance but when i change to 32 it breaks the filter, also if i pick a sort order then the dropdown for number of products doesn't work at all. 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