Back to Top

Override module in PrestaShop

Updated 7 August 2023

In this blog, we will learn how to override modules in PrestaShop. Sometimes, we need to enhance or modify the module feature then it is not recommended to modify the module file directly. If we modify the module files directly then in the future if you upgrade the module, all modifications will be lost. You can see the below PrestaShop official to know more about overriding:

We can override the below files of the module:

  • Main file
  • Controller files (front & admin)

Override module main file:

To override a module’s main class, you need to extend it and you have to provide the extended class the same name and add the Override suffix:

Searching for an experienced
Prestashop Company ?
Find out More

ie: If you want to override ps_shoppingcart module then the extended class name will be Ps_ShoppingcartOverride.

class Ps_ShoppingcartOverride extends Ps_Shoppingcart
    // Override the Ps_Shoppingcart methods here

Override module controller file:

You can override module admin and front controllers. To override module controllers, you have to do the same thing as done for overriding the module main class. You need to extend the controller class and provide the extended class the same name and add the Override suffix:

ie: If you want to override the ps_emailsubscription module front controller class Ps_EmailsubscriptionSubscriptionModuleFrontController then the extended class name should be Ps_EmailsubscriptionSubscriptionModuleFrontControllerOverride:

class Ps_EmailsubscriptionSubscriptionModuleFrontControllerOverride extends Ps_EmailsubscriptionSubscriptionModuleFrontController 
    public function postProcess()

In the same manner, you can also override the module admin controller. All overridden module files are moved to the PrestaShop override folder (override/modules/<MODULE_NAME>/) during the installation of the module.

That’s all about this blog.

If any issue or doubt please feel free to mention it in the comment section.

I would be happy to help.

Also, you can explore our PrestaShop Development Services & a large range of quality PrestaShop Modules.

For any doubt contact us at [email protected].

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*

Be the first to comment.

Back to Top

Message Sent!

If you have more details or questions, you can reply to the received confirmation email.

Back to Home