Push Notifications in Admin Panel in Prestashop

Push Notifications in Admin Panel in Prestashop

Today I will describe how push-notifications work in Prestаshоp. This article is written as a follow-up to this forum thread.

1Push Notifications

Default Prestashop features include the following functionalities: new orders, last registrations and open tickets. The module Gаmifiсаtiоn adds one more feature to this list.

There is the class “Notification” which can help to work with push-messages and which includes the following methods:

  • __construct() – contains the initialization of default types of messages:

  •  getLastElements() – selects recent entries from the «employer» table: id_last_order, id_last_customer_message, id_last_customer
  • getLastElementsIdsByType($type, $id_last_element) – returns all the element ids to show (order, customer registration, and customer message)
  • updateEmployeeLastElement($type) – Updates the last seen element by the employee

These methods are invoked by аjаx-requests, which are initialized from the file js/notification.js

To better understand the work flow of push-notification, we should check the following files:

  • adm/themes/default/template/header.tpl – includes html containers, whereto the data received via ajax is inserted
  • js/notification.js
  • classes/Notification.php

The module Gаmifiсаtiоn adds data by modifying html after the page is loaded, i.e. hooks to work with push-notification are not provided. The module uses just one hook: hookDisplayBackOfficeHeader. This hook is used only to connect the necessary js-files and libraries. So If you ever need to create your own custom push-notification, then you can use the files of the Gamification module as examples of best-practices.



2 comments

  1. ni,

    Its quite an old Prestashop version. Our support team (store@belvg.com) can help you with the update to the newest one.

Post a new comment

top