gerry293 Posted May 9, 2012 Share Posted May 9, 2012 Hi, I was previously using prestashop 1.25 and we had a fix to sort products by weight ( the weight you enter on the product global information at the first part of the page). Since I updated to 1.4 it seems many things have changed and I have been trying many ways but I can't seem to find the way to add the sorting by weight for my customers to use. I have seen the module to sort by attributes, but that is not what I am looking for as I don't want to add any attributes to my products. The weight is entered directly in the product description for customers to see and inside the product global information for the BO management. If anyone found a way to add this that would help me so much, Thanks Link to comment Share on other sites More sharing options...
phrasespot Posted May 10, 2012 Share Posted May 10, 2012 (edited) On 5/9/2012 at 10:46 AM, gerry293 said: Since I updated to 1.4 it seems many things have changed and I have been trying many ways but I can't seem to find the way to add the sorting by weight for my customers to use. When you ask a question like this, it would be helpful to let people know the exact version you have installed. Assuming you have the latest version installed (may or may not work with other versions) Locate the file /themes/[your theme]/product-sort.tpl. Within the select element insert the following, e.g., immediately before the closing tag for the element: <option value="weight:asc" {if $orderby eq 'weight' AND $orderway eq 'asc'}selected="selected"{/if}>{l s='Product Weight'}</option> This will sort lowest to highest weight, change all occurences of 'asc' with 'desc' if you want otherwise. Alternatively add a second similar line using 'desc' and change wording of 'Product Weight' in both lines. Then add the attached file to /override/classes/ directory Edited May 10, 2012 by phrasespot (see edit history) Link to comment Share on other sites More sharing options...
gerry293 Posted May 29, 2012 Author Share Posted May 29, 2012 Hello and thank you for your help. COuld you please let me know where is the attached file? Thank you. Link to comment Share on other sites More sharing options...
phrasespot Posted May 29, 2012 Share Posted May 29, 2012 On 5/29/2012 at 12:06 PM, gerry293 said: where is the attached file? Removed as it causes more problems than it helps when people try to use it without giving a second thought to the installed version. Let me know of the version you have and I will send you the appropriate change. 2 Link to comment Share on other sites More sharing options...
gerry293 Posted May 30, 2012 Author Share Posted May 30, 2012 You are right, sorry about the confusion, the version I am using is 1.4.5.1. Thanks again for your help. Link to comment Share on other sites More sharing options...
phrasespot Posted May 30, 2012 Share Posted May 30, 2012 (edited) On 5/30/2012 at 8:00 AM, gerry293 said: the version I am using is 1.4.5.1. Attached Edited May 30, 2012 by phrasespot (see edit history) Link to comment Share on other sites More sharing options...
gerry293 Posted May 30, 2012 Author Share Posted May 30, 2012 Hi, I inserted the file in the override folder and here is my code for the product-sort.tpl <form id="productsSortForm" action="{$request|escape:'htmlall':'UTF-8'}"> <p class="select"> <select id="selectPrductSort" onchange="document.location.href = $(this).val();"> <option value="{$link->addSortDetails($request, $orderbydefault, $orderwaydefault)|escape:'htmlall':'UTF-8'}" {if $orderby eq $orderbydefault}selected="selected"{/if}>{l s='--'}</option> {if !$PS_CATALOG_MODE} <option value="{$link->addSortDetails($request, 'price', 'asc')|escape:'htmlall':'UTF-8'}" {if $orderby eq 'price' AND $orderway eq 'asc'}selected="selected"{/if}>{l s='Price: lowest first'}</option> <option value="{$link->addSortDetails($request, 'price', 'desc')|escape:'htmlall':'UTF-8'}" {if $orderby eq 'price' AND $orderway eq 'desc'}selected="selected"{/if}>{l s='Price: highest first'}</option> {/if} <option value="{$link->addSortDetails($request, 'name', 'asc')|escape:'htmlall':'UTF-8'}" {if $orderby eq 'name' AND $orderway eq 'asc'}selected="selected"{/if}>{l s='Product Name: A to Z'}</option> <option value="{$link->addSortDetails($request, 'name', 'desc')|escape:'htmlall':'UTF-8'}" {if $orderby eq 'name' AND $orderway eq 'desc'}selected="selected"{/if}>{l s='Product Name: Z to A'}</option> <option value="weight:asc" {if $orderby eq 'weight' AND $orderway eq 'asc'}selected="selected"{/if}>{l s='Carat weight: lowest first'}</option> <option value="weight:desc" {if $orderby eq 'weight' AND $orderway eq 'desc'}selected="selected"{/if}>{l s='Carat weight: highest first'}</option> {if !$PS_CATALOG_MODE} {/if} </select> It is still not working, the words are showing on my webpage for product weight, but when clicked nothing happens. Thanks Link to comment Share on other sites More sharing options...
phrasespot Posted May 30, 2012 Share Posted May 30, 2012 Hmm. It should work. I tested on a 1.4.5.1 install. Send me link to where it is used. Link to comment Share on other sites More sharing options...
phrasespot Posted May 30, 2012 Share Posted May 30, 2012 On 5/30/2012 at 6:22 PM, phrasespot said: Hmm. It should work. I tested on a 1.4.5.1 install. Send me link to where it is used. Ah, that template code does not look like the default template from 1.4.5.1. Maybe you are using a theme which modifies the template. I think the following should work, replace with the change you already made to the template: <option value="{$link->addSortDetails($request, 'weight', 'desc')|escape:'htmlall':'UTF-8'}" {if $orderby eq 'weight' AND $orderway eq 'desc'}selected="selected"{/if}>{l s='Carat weight: highest first'}</option> <option value="{$link->addSortDetails($request, 'weight', 'asc')|escape:'htmlall':'UTF-8'}" {if $orderby eq 'weight' AND $orderway eq 'asc'}selected="selected"{/if}>{l s='Carat weight: lowest first'}</option> If this does not work, I suggest you seek professional help, I am sure it is within the reach of a diamond merchant Link to comment Share on other sites More sharing options...
gerry293 Posted May 31, 2012 Author Share Posted May 31, 2012 It still does not work, it seems the function can not load and sort the weight I enter in each product under the tab <weight (package):> I realize this is taking much of your time and even if I am not much of a diamond dealer, if you would like to offer your professional help, that would be fine, just let me know. Thanks again Link to comment Share on other sites More sharing options...
phrasespot Posted May 31, 2012 Share Posted May 31, 2012 On 5/31/2012 at 12:59 PM, gerry293 said: It still does not work, it seems the function can not load and sort the weight I enter in each product under the tab <weight (package):> I need to see the complete tpl, and maybe the theme. Attach the tpl here. I will ask for theme if I need it. Quote if you would like to offer your professional help, that would be fine, just let me know. Thanks. Not necessary. I don't pick up jobs from help threads I reply to. Link to comment Share on other sites More sharing options...
gerry293 Posted June 1, 2012 Author Share Posted June 1, 2012 {if isset($orderby) AND isset($orderway)} <!-- Sort products --> {if isset($smarty.get.id_category) && $smarty.get.id_category} {assign var='request' value=$link->getPaginationLink('category', $category, false, true)} {elseif isset($smarty.get.id_manufacturer) && $smarty.get.id_manufacturer} {assign var='request' value=$link->getPaginationLink('manufacturer', $manufacturer, false, true)} {elseif isset($smarty.get.id_supplier) && $smarty.get.id_supplier} {assign var='request' value=$link->getPaginationLink('supplier', $supplier, false, true)} {else} {assign var='request' value=$link->getPaginationLink(false, false, false, true)} {/if} <form id="productsSortForm" action="{$request|escape:'htmlall':'UTF-8'}"> <p class="select"> <select id="selectPrductSort" onchange="document.location.href = $(this).val();"> <option value="{$link->addSortDetails($request, $orderbydefault, $orderwaydefault)|escape:'htmlall':'UTF-8'}" {if $orderby eq $orderbydefault}selected="selected"{/if}>{l s='--'}</option> {if !$PS_CATALOG_MODE} <option value="{$link->addSortDetails($request, 'price', 'asc')|escape:'htmlall':'UTF-8'}" {if $orderby eq 'price' AND $orderway eq 'asc'}selected="selected"{/if}>{l s='Price: lowest first'}</option> <option value="{$link->addSortDetails($request, 'price', 'desc')|escape:'htmlall':'UTF-8'}" {if $orderby eq 'price' AND $orderway eq 'desc'}selected="selected"{/if}>{l s='Price: highest first'}</option> {/if} <option value="{$link->addSortDetails($request, 'name', 'asc')|escape:'htmlall':'UTF-8'}" {if $orderby eq 'name' AND $orderway eq 'asc'}selected="selected"{/if}>{l s='Product Name: A to Z'}</option> <option value="{$link->addSortDetails($request, 'name', 'desc')|escape:'htmlall':'UTF-8'}" {if $orderby eq 'name' AND $orderway eq 'desc'}selected="selected"{/if}>{l s='Product Name: Z to A'}</option> <option value="{$link->addSortDetails($request, 'weight', 'desc')|escape:'htmlall':'UTF-8'}" {if $orderby eq 'weight' AND $orderway eq 'desc'}selected="selected"{/if}>{l s='Carat weight: highest first'}</option> <option value="{$link->addSortDetails($request, 'weight', 'asc')|escape:'htmlall':'UTF-8'}" {if $orderby eq 'weight' AND $orderway eq 'asc'}selected="selected"{/if}>{l s='Carat weight: lowest first'}</option> {if !$PS_CATALOG_MODE} {/if} </select> <label for="selectPrductSort">{l s='Sort by'}</label> </p> </form> <!-- /Sort products --> {/if} The theme I use is the free prestashop theme called velvetsky. Thanks Link to comment Share on other sites More sharing options...
gerry293 Posted July 10, 2012 Author Share Posted July 10, 2012 Hello Phrasespot, Did you find any solution for my problem? Thank you for your time! Link to comment Share on other sites More sharing options...
phrasespot Posted July 10, 2012 Share Posted July 10, 2012 On 5/31/2012 at 3:50 PM, phrasespot said: I need to see the complete tpl, and maybe the theme. Attach the tpl here. I will ask for theme if I need it. On 7/10/2012 at 9:48 AM, gerry293 said: Did you find any solution for my problem? Did you do what I asked? Link to comment Share on other sites More sharing options...
gerry293 Posted July 12, 2012 Author Share Posted July 12, 2012 Hello, I don't follow exactly, I posted the complete product-sort.tpl file like you asked with the them I am using. Do you need any more information? Link to comment Share on other sites More sharing options...
phrasespot Posted July 12, 2012 Share Posted July 12, 2012 Sorry, my bad. I was expecting an attachment. Looked like a snippet. I will look into it later today. Link to comment Share on other sites More sharing options...
phrasespot Posted July 14, 2012 Share Posted July 14, 2012 It does work for me in 1.4.5.1 and every version after that using the product-sort.tpl you posted. I don't know why it does not work in your shop. Do other sorts work as they should? Make sure it is not a caching issue. Delete all files in /tools/smarty/compile/ directory except index.php and try again. Link to comment Share on other sites More sharing options...
iqdoom Posted July 15, 2012 Share Posted July 15, 2012 Can i have a /override/classes/ attachment? 1.4.4.0 (it wasn't my choice, so it's not latest version) Link to comment Share on other sites More sharing options...
gerry293 Posted July 16, 2012 Author Share Posted July 16, 2012 (edited) Hi thx for looking into it. I deleted the cache many times, cause I make many changes to the files. Also in my back office I enter the weight in the field called: Weight (package): Would the package word have anything that cause the problem ? Edited July 19, 2012 by gerry293 (see edit history) Link to comment Share on other sites More sharing options...
phrasespot Posted July 16, 2012 Share Posted July 16, 2012 Quote I enter the weight in the field called: Weight (package):. Would the package word have anything that cause the problem ? No, but make sure you are entering numbers into that field and nothing else. Link to comment Share on other sites More sharing options...
gerry293 Posted July 17, 2012 Author Share Posted July 17, 2012 I Just enter the weight for example: 1.23 Have you seen the website ? any idea why it does not work. Link to comment Share on other sites More sharing options...
phrasespot Posted July 17, 2012 Share Posted July 17, 2012 Quote Have you seen the website ? Yes Quote any idea why it does not work. You added the override, right? If so no Link to comment Share on other sites More sharing options...
gerry293 Posted July 17, 2012 Author Share Posted July 17, 2012 Yes I added the override... Could you send it again so I can make sure it is the right one I added. Thanks If it doesn't work, what would you suggest? would mind looking at it? Link to comment Share on other sites More sharing options...
fernandodelgado Posted February 4, 2015 Share Posted February 4, 2015 (edited) Hi, I need to put in the lists of products the ability to sort by weight. I put the following in the product-sort.tpl of my template. <option value="weight:asc" {if $orderby eq 'weight' AND $orderway eq 'asc'}selected="selected"{/if}>{l s='Carat weight: lowest first'}</option> <option value="weight:desc" {if $orderby eq 'weight' AND $orderway eq 'desc'}selected="selected"{/if}>{l s='Carat weight: highest first'}</option> but although it appears, is no sorting by weight. What else should I change? What other file should be modified to effectively sort by weight? Prestashop 1.6.0.9 Edited February 4, 2015 by fernandodelgado (see edit history) Link to comment Share on other sites More sharing options...
fernandodelgado Posted February 10, 2015 Share Posted February 10, 2015 (edited) I write again, since no one has answered me ... The solution I found to work is adding weight $ order_by_values = array (0 => 'name', 1 => 'price', 2 => 'DATE_ADD', 3 => 'date_upd', 4 => 'position', 5 => 'manufacturer_name', 6 => 'quantity', 7 => 'reference', 8 => 'weight'); in classes/controller/FrontController.php Thus working properly, the problem is that it does not work when the blocklayerd is active. I do not know what changes need to do to make the ability to sort by weight when the module blocklayered, is active is added. Edited February 10, 2015 by fernandodelgado (see edit history) 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