How to Create Custom Reports Based on Statistics Module in Prestashop

How to Create Custom Reports Based on Statistics Module in Prestashop

In this article we will explain how to create a statistics module (the module is avaliable at the end of the article).

Such types of modules are available under the tab Bасkend-> Stаts-> Stаts:

1_How to Create Custom Reports Based on Statistics Module in Prestashop

 

This page is generated by the controller “AdminStatsController”, which is inherited from the controller “AdminStatsTabController”. The latter uses the method “protected function getMоdules()” to send the following request to determine which modules are related to the statistics:

Once one of our customers asked to generate the following type of report:

is it possible to make a report in prestashop that shows how many new products are created by category and by employee (they log on with the own login).

That is why to help him we created this module.

There are 2 methods (for standard modules) to implement this type of modules:

  1. Inherit from the class Module
  2. Inherit from the class ModuleGrid

In the second way you should implement the abstract method getData() where to implement the logic to get entries for the statistics. Basically, the second method presupposes that there should be a specific list, while the first method allows us output data just the way we want.

The module with the class MоduleGrid is similar to the admin controller, that with the help of the method  ‘public function engine( $params)’ generates HTML with results in the form of a table.

2_How to Create Custom Reports Based on Statistics Module in Prestashop

Here is the example of the code of one of our statistics modules:

 

Download the module here.



Post a new comment

top