* @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 = 'analytics_stats'; $this->version = '2.0.1'; $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.', array(), 'Modules.Statsbestproducts.Admin'); $this->paging_message = $this->trans('Displaying %1$s of %2$s', array('{0} - {1}', '{2}'), 'Admin.Global'); $this->columns = array( array( 'id' => 'reference', 'header' => $this->trans('Reference', array(), 'Admin.Global'), 'dataIndex' => 'reference', 'align' => 'left' ), array( 'id' => 'name', 'header' => $this->trans('Name', array(), 'Admin.Global'), 'dataIndex' => 'name', 'align' => 'left' ), array( 'id' => 'totalQuantitySold', 'header' => $this->trans('Quantity sold', array(), 'Admin.Global'), 'dataIndex' => 'totalQuantitySold', 'align' => 'center' ), array( 'id' => 'avgPriceSold', 'header' => $this->trans('Price sold', array(), 'Modules.Statsbestproducts.Admin'), 'dataIndex' => 'avgPriceSold', 'align' => 'right' ), array( 'id' => 'totalPriceSold', 'header' => $this->trans('Sales', array(), 'Admin.Global'), 'dataIndex' => 'totalPriceSold', 'align' => 'right' ), array( 'id' => 'averageQuantitySold', 'header' => $this->trans('Quantity sold in a day', array(), 'Modules.Statsbestproducts.Admin'), 'dataIndex' => 'averageQuantitySold', 'align' => 'center' ), array( 'id' => 'totalPageViewed', 'header' => $this->trans('Page views', array(), 'Modules.Statsbestproducts.Admin'), 'dataIndex' => 'totalPageViewed', 'align' => 'center' ), array( 'id' => 'quantity', 'header' => $this->trans('Available quantity for sale', array(), 'Admin.Global'), 'dataIndex' => 'quantity', 'align' => 'center' ), array( 'id' => 'active', 'header' => $this->trans('Active', array(), 'Admin.Global'), 'dataIndex' => 'active', 'align' => 'center' ) ); $this->displayName = $this->trans('Best-selling products', array(), 'Modules.Statsbestproducts.Admin'); $this->description = $this->trans('Enrich your stats with a small list of your best-sellers to better know your customers.', array(), 'Modules.Statsbestproducts.Admin'); $this->ps_versions_compliancy = array('min' => '1.7.6.0', 'max' => _PS_VERSION_); } public function install() { return (parent::install() && $this->registerHook('displayAdminStatsModules')); } public function hookDisplayAdminStatsModules($params) { $engine_params = array( '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 '