Jump to content

why the best seller moudle does not work well?


Locus2010

Recommended Posts

I used the prestatshop for more than one year.but what the problem i found is that the best seller model can not work well.all of our customers make the order online,but always can not show the best seller products automatically.what happened to this model,is there anybody know how to solve it,tks a lot for your attention and solution suggestion from everyone.

tks &best;regards !

Link to comment
Share on other sites

I also found this modules quantities wasn't being updated when products were sold so I did a small script that I run at the end of every day. Can set up a cron job to do this on a daily basis. This updates the quantities for the table that the best sellers module uses.

Use the following code, save it as a php file, name is something like sync_sales.php and stick it on your server, and call it from a browser when you need to (will show a blank/white page)

<?php

include(dirname(__FILE__).'/config/config.inc.php');
include(dirname(__FILE__).'/init.php');

return Db::getInstance()->Execute('
   REPLACE INTO '._DB_PREFIX_.'product_sale
   (`id_product`, `quantity`, `sale_nbr`, `date_upd`)
   SELECT od.product_id, COUNT(od.product_id), SUM(od.product_quantity), NOW()
       FROM '._DB_PREFIX_.'order_detail od 
       GROUP BY od.product_id');

?>



In my opinion the best sales should be those products that have sold the most quantities, but Prestahop does not figure it that way, it counts how many times the product was sold on a per order basis, so you need to alter the code in "classes/ProductSale.php" to change this.

find

ps.`quantity` AS sales



replace with

ps.`sale_nbr` AS sales



This code occurs twice in that file, once for the block and the other for the best-sales page.

Hope this helps. :)

Link to comment
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...