* @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) */ if (!defined('_PS_VERSION_')) { exit; } class statsbestproducts extends ModuleGrid { private $html = null; private $query = null; private $columns = null; private $default_sort_column = null; private $default_sort_direction = null; private $empty_message = null; private $paging_message = null; public function __construct() { $this->name = 'statsbestproducts'; $this->tab = 'administration'; $this->version = '2.1.0'; $this->author = 'PrestaShop'; $this->need_instance = 0; parent::__construct(); $this->default_sort_column = 'totalPriceSold'; $this->default_sort_direction = 'DESC'; $this->empty_message = $this->trans('An empty record-set was returned.', [], 'Modules.Statsbestproducts.Admin'); $this->paging_message = $this->trans('Displaying %1$s of %2$s', ['{0} - {1}', '{2}'], 'Admin.Global'); $this->columns = [ [ 'id' => 'reference', 'header' => $this->trans('Reference', [], 'Admin.Global'), 'dataIndex' => 'reference', 'align' => 'left', ], [ 'id' => 'name', 'header' => $this->trans('Name', [], 'Admin.Global'), 'dataIndex' => 'name', 'align' => 'left', ], [ 'id' => 'totalQuantitySold', 'header' => $this->trans('Quantity sold', [], 'Admin.Global'), 'dataIndex' => 'totalQuantitySold', 'align' => 'center', ], [ 'id' => 'avgPriceSold', 'header' => $this->trans('Price sold', [], 'Modules.Statsbestproducts.Admin'), 'dataIndex' => 'avgPriceSold', 'align' => 'right', ], [ 'id' => 'totalPriceSold', 'header' => $this->trans('Sales', [], 'Admin.Global'), 'dataIndex' => 'totalPriceSold', 'align' => 'right', ], [ 'id' => 'averageQuantitySold', 'header' => $this->trans('Quantity sold in a day', [], 'Modules.Statsbestproducts.Admin'), 'dataIndex' => 'averageQuantitySold', 'align' => 'center', ], [ 'id' => 'totalPageViewed', 'header' => $this->trans('Page views', [], 'Modules.Statsbestproducts.Admin'), 'dataIndex' => 'totalPageViewed', 'align' => 'center', ], [ 'id' => 'quantity', 'header' => $this->trans('Available quantity for sale', [], 'Admin.Global'), 'dataIndex' => 'quantity', 'align' => 'center', ], [ 'id' => 'active', 'header' => $this->trans('Active', [], 'Admin.Global'), 'dataIndex' => 'active', 'align' => 'center', ], ]; $this->displayName = $this->trans('Best-selling products', [], 'Modules.Statsbestproducts.Admin'); $this->description = $this->trans('Enrich your stats with a small list of your best-sellers to better know your customers.', [], 'Modules.Statsbestproducts.Admin'); $this->ps_versions_compliancy = ['min' => '1.7.6.0', 'max' => _PS_VERSION_]; } public function install() { return parent::install() && $this->registerHook('displayAdminStatsModules'); } public function hookDisplayAdminStatsModules($params) { $engine_params = [ 'id' => 'id_product', 'title' => $this->displayName, 'columns' => $this->columns, 'defaultSortColumn' => $this->default_sort_column, 'defaultSortDirection' => $this->default_sort_direction, 'emptyMessage' => $this->empty_message, 'pagingMessage' => $this->paging_message, ]; if (Tools::getValue('export')) { $this->csvExport($engine_params); } return '