Jump to content

The correct way of changing PrestaShop code.


kramlv

Recommended Posts

So, for example if I want to hide field in tpl (I use "hide" class), or I want to configure permanent BCC in mail.php I can do it without touching source, by creating override files?

 

I am asking about correct development concept, because I want to make changes, that are upgradable.

 

 

P.S. Started to investigate links, that You mentioned. I can not understand, how I point at what place override should put additions or changes. Can You please help?

 

 

Thank You.

Edited by kramlv (see edit history)
Link to comment
Share on other sites

Simply find the class or controller you want to change and then create a file with the same directory and filename inside the override directory in the root. For example, if you want to override classes/Address.php, create override/classes/Address.php with the following:
<?php

class Address extends AddressCore
{

}

You can then choose to override a function like this:

public function __construct()
{
    AddressCore::$definition['fields']['lastname']['size'] = 64;
    parent::__construct();
}

You can choose to add your own code and then call the parent function, call the parent function first and then add your own code, or you can copy the parent function in it's entirety and modify any part of the code you want.

 

You also need to go to Advanced Parameters > Performance and click the "Clear cache" button (or manually delete cache/class_index.php) each time you add an override so PrestaShop can find it.

Link to comment
Share on other sites

Yes, to override a module's TPL file, CSS or JavaScript, copy it to themes/<your_theme>/modules/<module_name>/<template_name>, themes/<your_theme>/css/modules/<module_name>/<stylesheet_name> or themes/<your_theme>/js/modules/<module_name>/<javascript_name> directories.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...