I would like to change existing prestashop module without copying it and creating new one. I know that it is possible to override .tpl files in prestashop, but is it possible to do same thing with php classes? For instance I would like to change blockcart so that it can be hooked on top. Since original version doesnt have that hook I need to change install() function! I can`t change original source (it would be bad idea isn't it...) file I need to override install() function by inheriting blockcart module. Is it possible to do so and where I can find example?
I use my own override to the FrontController class to allow the display of module output at arbitrary points in tpl files - this means that the module doesn't need to support a particular hook. It is implemented via a smarty plugin, so you can for example use:
{plugin module='blockcart' hook='rightColumn'}
The above will force the module to output what it would display if hooked to the right column where the above is tag inserted (which can be anywhere in any tpl file). You can "unhook" the module from the right column so that it only displays where you want it to using this technique. I have used it on a production site with great success.
There's a series of articles describing how it works (with the required code) available at:
Prestashop 1.4 Plugins
In Prestashop 1.4 you can override core classes and module templates Today this is not possible to override a module php file but we are working on it.
in override\modules\blockcart\blockcart.php (create it if it does not exist yet)
<?php
class BlockCartOverride extends BlockCart
{
public function hookDisplayTop($params)
{
return parent::hookTop($params);
}
}
?>
like this you can override any module to be hookable on any default or custom hook. don't forget to delete cache/class_index.php for the override to work :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With