Solaris Posted September 24, 2012 Share Posted September 24, 2012 I would like to order my products (in every category) by the product id (id_product). Could anyone point me to the right file? I have tried to add the following to product-sort.tpl: <option value="id_product:asc" {if $orderby eq 'id_product' AND $orderway eq 'asc'}selected="selected"{/if}>{l s='Product ID: ASC'}</option> But that did only show the option in the front end, but it doesn't sort when selected. - How can I change the above code so it works? - How can I modify the shop so I can set the default sort order in the backend? - If none of the above works, can I "dirty-hack" a SQL query so it order by 'id_product' ? Thanks a lot for your inputs! Link to comment Share on other sites More sharing options...
Carolina Custom Designs Posted September 24, 2012 Share Posted September 24, 2012 What PS version are you using? In all the newer versions you can arrange your products in any order you want. All you have to do is drag and drop them. Hope that helps! Marty Shue Link to comment Share on other sites More sharing options...
Solaris Posted September 25, 2012 Author Share Posted September 25, 2012 Thanks for your reply! I can't move the items in the catalog - should this be possible on the admin page catalog > products? I am using 1.5.0.17, the sorting is set to position in category and I have tried using safari and firefox. Link to comment Share on other sites More sharing options...
Andrew R Posted September 25, 2012 Share Posted September 25, 2012 You need to add an extra item in Tools.php > getProductsOrder(). For some reason, they missed out id_product in the array. Just change: $list = array(0 => 'name', 1 => 'price', 2 => 'date_add', 3 => 'date_upd', 4 => 'position', 5 => 'manufacturer_name', 6 => 'quantity'); to the following: $list = array(0 => 'name', 1 => 'price', 2 => 'date_add', 3 => 'date_upd', 4 => 'position', 5 => 'manufacturer_name', 6 => 'quantity', 7=>'id_product'); Your extra option button would be something like: <option value="{$link->addSortDetails($request, 'id_product', 'asc')|escape:'htmlall':'UTF-8'}" {if $orderby eq 'id_product' AND $orderway eq 'asc'}selected="selected"{/if}>{l s='Product ID: low to high'}</option> Link to comment Share on other sites More sharing options...
Carolina Custom Designs Posted September 25, 2012 Share Posted September 25, 2012 You can follow Andrew's advice or you could go to Catalog > Products then check 'Filter by category'. Now just select the category you would like to organize. Once the products in that category are loaded simply drag n' drop the products in the order you want. Hope that helps! Marty Shue Link to comment Share on other sites More sharing options...
Solaris Posted September 27, 2012 Author Share Posted September 27, 2012 Thank you both VERY much for your replies! I cannot get it to work unfortunately. I have inserted the code into the two pages (Tools.php and product_sort.tpl), and the sort order can now be selected. However it doesn't sort. So I made it display the value of the two sort order variables ("",""), which switch to Name,desc or _asc when I select to order by product ID. Could it be there's a problem with Smarty's Sort feature and the field "id_product" ? I see that the Front Controller gives the sort command to Smarty using public function productSort(). Or doesn't PS know about the 'id_product'? When I use the URL that is being returned by the addSortDetails function, it doesnt sort either (http://www.tomandi.ch/2013/index.php?id_category=3&controller=category&id_lang=2&id_lang=2&orderby=id_product&orderway=desc) So if anyone is _still_ willing to help, it would be much appreciated. Thanks! Link to comment Share on other sites More sharing options...
Andrew R Posted September 27, 2012 Share Posted September 27, 2012 (edited) Or doesn't PS know about the 'id_product'? When I use the URL that is being returned by the addSortDetails function, it doesnt sort either (http://www.tomandi.c...t&orderway=desc) It looks like it's working ok for descending but not ascending. What is the code you pasted in product_sort.tpl for the ascending option? It should be: <option value="{$link->addSortDetails($request, 'id_product', 'asc')|escape:'htmlall':'UTF-8'}" {if $orderby eq 'id_product' AND $orderway eq 'asc'}selected="selected"{/if}>{l s='Product ID: low to high'}</option> <option value="{$link->addSortDetails($request, 'id_product', 'desc')|escape:'htmlall':'UTF-8'}" {if $orderby eq 'id_product' AND $orderway eq 'desc'}selected="selected"{/if}>{l s='Product ID: high to low'}</option> Edited September 27, 2012 by Andrew R (see edit history) Link to comment Share on other sites More sharing options...
Mezza Posted April 21, 2013 Share Posted April 21, 2013 (edited) Hi Marty, I'm trying to do as you said, dragging and droping within the category but there's no drag and drop bit. Edit: Found it! Edited April 21, 2013 by Mezza (see edit history) Link to comment Share on other sites More sharing options...
Scully Posted September 3, 2014 Share Posted September 3, 2014 Sorting by id_product --> see solution for PS 1.5. under this link: http://www.prestashop.com/forums/topic/236006-product-sort-by-id/ 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