Jump to content

Best Sales / Top Sellers module sorting backwards


Recommended Posts

So I'm using the default best sales/top sellers module in prestashop but when you click on the module to go to the grid list of products, it seems to sort them backwards; putting the best sellers at the last page. How can I fix/reverse this?

Link to comment
Share on other sites

  • 2 weeks later...

I had this issue recently too. I solved it modifying function getBestSales() in classes/ProductSale.php:

 

ORDER BY '.(isset($orderByPrefix) ? $orderByPrefix.'.' : '').'`'.pSQL($orderBy).'` '.pSQL($orderWay).'

 

by

 

ORDER BY '.(isset($orderByPrefix) ? $orderByPrefix.'.' : '').'`'.pSQL($orderBy).'` DESC

Edited by Velocity (see edit history)
Link to comment
Share on other sites

I had this issue recently too. I solved it modifying classes/ProductSale.php:

 

ORDER BY '.(isset($orderByPrefix) ? $orderByPrefix.'.' : '').'`'.pSQL($orderBy).'` '.pSQL($orderWay).'

 

by

 

ORDER BY '.(isset($orderByPrefix) ? $orderByPrefix.'.' : '').'`'.pSQL($orderBy).'` DESC

 

thanks for the solution im going to check it :-)

@Jasen can you check this solution, please?

Link to comment
Share on other sites

  • 1 month later...
  • 2 weeks later...
  • 3 months later...

Anyone have the fix for 1.5? Can't find ORDER BY '.(isset($orderByPrefix) ? $orderByPrefix.'.' : '').'`'.pSQL($orderBy).'` '.pSQL($orderWay).'  in my file so I'm assuming this isn't for 1.5  

 

there is code:

ORDER BY '.(!empty($order_table) ? '`'.pSQL($order_table).'`.' : '').'`'.pSQL($order_by).'` '.pSQL($order_way).'
Link to comment
Share on other sites

 

there is code:

ORDER BY '.(!empty($order_table) ? '`'.pSQL($order_table).'`.' : '').'`'.pSQL($order_by).'` '.pSQL($order_way).'

 

and for 1.5.4.1?

in classes\ProductSale.php in getBestSales function I have:

ORDER BY `'.pSQL($order_by).'` '.pSQL($order_way).'

in the same function at the beggining I have:

if (is_null($order_way) || $order_by == 'sales') $order_way == 'DESC';

and in function getBestSalesLight I have:

ORDER BY sales DESC

and on best-sales page tha last item is the most often bought one?

Link to comment
Share on other sites

and for 1.5.4.1?

in classes\ProductSale.php in getBestSales function I have:

ORDER BY `'.pSQL($order_by).'` '.pSQL($order_way).'

in the same function at the beggining I have:

if (is_null($order_way) || $order_by == 'sales') $order_way == 'DESC';

and in function getBestSalesLight I have:

ORDER BY sales DESC

and on best-sales page tha last item is the most often bought one?

 

hi, i fixed problem.

 

incorrect line:    if (is_null($order_way) || $order_by == 'sales') $order_way = 'DESC';

actually line:     if (is_null($order_way) || $order_by == 'sales') $order_way =='DESC';

 

= There are two units need to have this character, but the first one.

Link to comment
Share on other sites

Hi kancanli, thx for a quick reply.

 

But as I quoted above, I have "==" in my file. I don't have line with:

$order_way = 'DESC';

which you marked as incorrect, so I completely can't understand your solution. :|

Link to comment
Share on other sites

  • 4 weeks later...

Hi. It's line 73 in that file where I have if (is_null($order_way) || $order_by == 'sales') $order_way = 'DESC';

 

If you find it, just change to =='DESC';

Link to comment
Share on other sites

  • 1 month later...

in template file (product-list.tpl) you can use two if conditions:

{if $controller=="best-sales"}
    {if $product.price != 0}
        CODE TO DISPLAY PRODUCT HERE
    {/if}
{else}
CODE TO DISPLAY PRODUCT HERE
{/if}

this is the simplest way, better one is a modification of controller, but it's not as easy as code above.

Link to comment
Share on other sites

  • 2 weeks later...

Finally I resolved my problem in this way:

in the file 'classes\ProductSale.php' in function 'getBestSalesLight' after 'WHERE product_shop.`active` = 1'  put the line

 

'AND p.`price` > 0'

 

maybe it isnt very good idea to change the main file and would have problem for updating to another versions 

by the way thanks for your notice and dont hesitate to give ur opinion to my store

Edited by payamtooba (see edit history)
Link to comment
Share on other sites

  • 1 year later...

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...