Get Free Audit

Push Notifications in Admin Panel in Prestashop

Jun 27, 2014

5950 Alex Simonchik

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:

Igor Dragun
Partner With Us Let's discuss how to grow your business. Get a Free Quote.
Talk to Igor

  •  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.

Igor Dragun
Partner With Us Looking for a partner to grow your business? We are the right company to bring your webstore to success. Talk to Igor

2 Comments

Post a new comment

BelVG Newsletter
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.
Email *