Note: on a CMS such as Prestashop, always try using a hook, or override a function, to implement what needs to be done.
But when this is not possible, a shutdown function can be used.

Principle

void register_shutdown_function ( callable $callback [, mixed $parameter [, mixed $... ]] )
Registers a callback to be executed after script execution finishes or exit() is called.

Multiple calls to register_shutdown_function() can be made, and each will be called in the same order as they were registered. If you call exit() within one registered shutdown function, processing will stop completely and no other registered shutdown functions will be called.

Parameters

callback: The shutdown callback (usually a function) to register. The shutdown callbacks are executed as the part of the request, so it's possible to send output from them and access output buffers.
parameter: It is possible to pass parameters to the shutdown function by passing additional parameters.

Return Values

No value is returned.

Errors/Exceptions

If the passed callback is not callable a E_WARNING level error will be generated.

Example

< ?php
function shutdown()
{
// This is our shutdown function, in
// here we can do any last operations
// before the script is complete.

echo 'Script executed with success', PHP_EOL;
}

register_shutdown_function('shutdown');
?>