Jump to content

Recommended Posts

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

  • 10 months later...

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

  • 5 months later...
  • 2 weeks later...

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>

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

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 by Lucagiaicheca (see edit history)
Link to comment
Share on other sites

×
×
  • Create New...