T.Baron Posted February 15, 2016 Share Posted February 15, 2016 Hi, So we've had this problem for a long time. The best sellers module (prestashop's official module) is showing apparently random products. The list is always the same, however it doesn't fit the best sellers list I can see in stats. I've tried to reinstall best sellers modules, the block and the stats ones, which displayed other products but still wrong ones. I've looked at the php and the getBestSellers method doesn't seem to get the best selling products and instead is fixing prices from a list. Here's the code of the function : protected function getBestSellers($params) { if (Configuration::get('PS_CATALOG_MODE')) return false; if (!($result = ProductSale::getBestSalesLight((int)$params['cookie']->id_lang, 0, (int)Configuration::get('PS_BLOCK_BESTSELLERS_TO_DISPLAY')))) return (Configuration::get('PS_BLOCK_BESTSELLERS_DISPLAY') ? array() : false); $currency = new Currency($params['cookie']->id_currency); $usetax = (Product::getTaxCalculationMethod((int)$this->context->customer->id) != PS_TAX_EXC); foreach ($result as &$row) $row['price'] = Tools::displayPrice(Product::getPriceStatic((int)$row['id_product'], $usetax), $currency); return $result; } Any help and any tip is welcome ! Thanks Link to comment Share on other sites More sharing options...
tuk66 Posted February 15, 2016 Share Posted February 15, 2016 Have a look at the ProductSale::getBestSalesLight method. For me, it gets best selling products. Link to comment Share on other sites More sharing options...
T.Baron Posted February 16, 2016 Author Share Posted February 16, 2016 Thanks tuk66 ! I'm looking at it right now. I'll post further informations if I solved this problem or if I find anything relevant to it. Link to comment Share on other sites More sharing options...
zod Posted March 4, 2017 Share Posted March 4, 2017 (edited) Hi T.Baron, i had your same issue. Eventually i discovered my problem, it was not related to the core module "Best Sellers" but to another one, bundled in a "Leo Theme".The module is "Leo Manage Widgets", it has a Widget to manage all the usual tabs in a Owl Carousel, so we have: "Best Sales Products", "Featured Products", "Special Products", "New Arrivals". The problem is the configuration: it is sharing the Order By and Order Way between ALL tabs, and this is wrong because for the Best Sales we need the order by "sales" and "DESC" (for this reason i had a problem, it was showing the same products by title). Also, in the select field you don't have "sales", not a valid option for all tabs anyway. It is a mess... so i changed behaviour in the code.The file to modify is here: /modules/leotempcp/classes/widget/producttabs.phpI found another module, and i modified this one the first time, by mistake, i am not sure why Leo Theme did 2 modules with the same files: /modules/leomanagewidgets/classes/widget/producttabs.phpSo, the solution is to modify row 256 (both files, they are identical), from this code: $pro_bestseller = ProductSale::getBestSales((int)(Context::getContext()->language->id), 0, $nb, $orderby, $orderway); To this code, if you want change the function from "getBestSales" to "getBestSalesLight" (it has 2 params less): $pro_bestseller = ProductSale::getBestSalesLight((int)(Context::getContext()->language->id), 0, $nb); Or you can keep "getBestSales" but changing the last 2 params to force "sales" and "DESC" (it is the default behaviour of "getBestSalesLight"): $pro_bestseller = ProductSale::getBestSales((int)(Context::getContext()->language->id), 0, $nb, 'sales', 'DESC'); Perhaps you could use this function to solve your problem T.Baron. I am not sure if your problem is in the core module of Prestashop, anyway this should be the fix according your code: if (!($result = ProductSale::getBestSales((int)$params['cookie']->id_lang, 0, (int)Configuration::get('PS_BLOCK_BESTSELLERS_TO_DISPLAY'), 'sales', 'DESC'))) Edited March 4, 2017 by zod (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now