Lucagiaicheca Posted March 29, 2013 Share Posted March 29, 2013 Hi, I'm trying to make the product-sort.tpl display products by id, but NO WAY to make it work. I found some other Topics about this, but none of them is solved, so I try to take the attention back to this some kind of beginner problem... :-) This is what I did, without success: FIRST TRIAL: 1. On product-sort.tpl: <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> 2. On Tools.php (in classes folder): $list = array(0 => 'name', 1 => 'price', 2 => 'date_add', 3 => 'date_upd', 4 => 'position', 5 => 'manufacturer_name', 6 => 'quantity', 7=>'id_product'); When you click it, in the frontend, it simply switch to A-Z order. SECOND TRIAL: 1. On product-sort.tpl: <option value="id_product:desc" {if $orderby eq 'id_product' AND $orderway eq 'desc'}selected="selected"{/if}>{Order by id}</option> pleeeaaase super-developer I know you're there and you know the magic words to make it work!!! :-) Link to comment Share on other sites More sharing options...
Tomasci Posted February 25, 2014 Share Posted February 25, 2014 Hi there! I guess this was solved? I am new to PrestaShop and have been ordering products by ID while adding new products. Everything was fine and after saving new product it would appear as first due to my sorting. Since I reached 350 it doesn't do that anymore for some reason, weird! Also the ordering by category or anything else for that matter loses it's memory every time I press a button. Any advice? It is a very usefull feature. Thanks! Link to comment Share on other sites More sharing options...
Scully Posted August 21, 2014 Share Posted August 21, 2014 Same here on 1.5.6.2. We also did the changes accorings Lucagiaicheca initial post. However, if we select sort by ID, it goes back to A-Z. Link to comment Share on other sites More sharing options...
Scully Posted September 3, 2014 Share Posted September 3, 2014 Sort by id_product works in PS 1.5. if you change the following: 1) In /root/classes/controller/FrontController.php, public function productSort -> around line 820: $order_by_values = array(0 => 'name', 1 => 'price', 2 => 'date_add', 3 => 'date_upd', 4 => 'position', 5 => 'manufacturer_name', 6 => 'quantity' , 7 => 'p.id_product'); The prefix p. is necessary since the underlying sql retrieves all columns from ps_product as well as ps_product_shop and both tables have id_product as columns. 2) Then in the /themes directory, change the file product-sort.tpl add a line as follows (please also use the p. prefix): <option value="p.id_product:desc" {if $orderby eq 'p.id_product' AND $orderway eq 'desc'}selected="selected"{/if}>{l s='newest products'}</option> 1 Link to comment Share on other sites More sharing options...
vekia Posted September 3, 2014 Share Posted September 3, 2014 date_add is equal to product id :-) Link to comment Share on other sites More sharing options...
shqvarny Posted October 13, 2014 Share Posted October 13, 2014 For me this p.id_product works well, don't know why date_add was displaying same as in order by name. Link to comment Share on other sites More sharing options...
Lucagiaicheca Posted October 14, 2014 Author Share Posted October 14, 2014 (edited) Now I will try to apply Scully's code, fingers crossed! Vekia, it is not true that date_add is the same as ID, in my case at least. When I edit a product, I don't know why it updates both date_add and date_update. Don't know why, but the result is that even if I want new products to display first, if I edit something it jumps in pole position. So I have to connect to cPanel and change date_add. Weird, but it's what's going on here. Kind Regards. Edited October 14, 2014 by Lucagiaicheca (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts