Jump to content
zloeloshadko

[SOLVED] how to set product sort in shopping cart (sort by name)

Recommended Posts

 
Hi!
I use prestashop 1.5.6.1

I have in my store about 15,000 goods and when a customer makes an order for maybe 400 items it is difficult for him to verify the order in the cart (i mean shopping-cart.tpl) because the products are sorted by id.
How to sort products in cart by name?
Is it possible maybe to use standart product-sort.tpl in the cart summary?
 
Thank you for any answers!

 

Share this post


Link to post
Share on other sites

change order by clause in

$sql->orderBy('p.id_product, cp.id_product_attribute, cp.date_add ASC');

to
 

$sql->orderBy('pl.name ASC, cp.id_product_attribute, cp.date_add ASC'); 

your list will be sortted by product name ASCENDING (pl.name ASC)

 

it's a part of classes/Cart.php (getProducts()) funciton

  • Like 2

Share this post


Link to post
Share on other sites

Thank you again and again!

 

It works, but after that the customer asked me to make order by 'last added from top' so i make this:

$sql->orderBy('cp.date_add DESC'); 

It works too, but is it okay to leave it like that?

 

---------

Solved

Share this post


Link to post
Share on other sites

yes everything is fine with your code :)

you don't have to worry

 

topic marked as solved.

with regards,

Milos

  • Like 1

Share this post


Link to post
Share on other sites

Is that possible to use a solution like this to order the products in cart, order and invoice by REFERENCE number (SKU), instead of PRODUCT_ID or NAME (pl.name)?

 

It works with:

466     $sql->orderBy('p.reference, cp.id_product_attribute, p.id_product, cp.date_add ASC');

 

PS vs. 1.5.5.0

Edited by gabiatti (see edit history)

Share this post


Link to post
Share on other sites

Is that possible to use a solution like this to order the products in cart, order and invoice by REFERENCE number (SKU), instead of PRODUCT_ID or NAME (pl.name)?

 

It works with:

466     $sql->orderBy('p.reference, cp.id_product_attribute, p.id_product, cp.date_add ASC');

 

PS vs. 1.5.5.0

use unique_id instead of pl.name

Share this post


Link to post
Share on other sites

change order by clause in

$sql->orderBy('p.id_product, cp.id_product_attribute, cp.date_add ASC');

to

 

$sql->orderBy('pl.name ASC, cp.id_product_attribute, cp.date_add ASC'); 

your list will be sortted by product name ASCENDING (pl.name ASC)

 

it's a part of classes/Cart.php (getProducts()) funciton

 

That is by far the simplest solution, but of course changing the core code can give you problems when updating PrestaShop.

 

Overriding, of course, can also give you problems, but the chances are not as great, my post on how to sort by original date add can be modified to do the same without changing the core code.

Share this post


Link to post
Share on other sites

Hello everyone. It is possible sort the products order by EAN-13 or UPC field??

 

I dont use this fields and I would like sort the orders invoice because my store and stock is too big. 

 

Reference numbers and another fields are disordered. I need a new field to sort.

 

Thanks and regards

Share this post


Link to post
Share on other sites

change order by clause in

$sql->orderBy('p.id_product, cp.id_product_attribute, cp.date_add ASC');

to

 

$sql->orderBy('pl.name ASC, cp.id_product_attribute, cp.date_add ASC'); 

your list will be sortted by product name ASCENDING (pl.name ASC)

 

it's a part of classes/Cart.php (getProducts()) funciton

will this work with ps 1.6.1.6 as well?

Share this post


Link to post
Share on other sites

how about when adding products to the cart it ads the product to the bottom of the cart and the coustomer needs to scroll to se the last added product. can i add the latest on the på in the ajax cart animation. our cartblock is alwas open.  ? 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More