Jump to content

Location of override files in modules


musicmaster
 Share

Recommended Posts

I recently added a tool to Prestools that shows you which overrides your webshop has.

 

To do that I look for files. If a modules has an override directory then I can find which overrides it has and when I find the same overrides in the main override directory I know where they cam from.

 

Problem is that I found that the OnePageCheckout module of PresTeamShop does not has an override directory in its root but instead has an override subdirectory beneath a "public" directory. That raises the questions whether other modules have their overrides somewhere else too and what the rules are for that. 

 

Can anyone enlighten me?

Edited by musicmaster (see edit history)

Share this post


Link to post
Share on other sites

before prestashop automatically installed overrides, it was the modules job to copy the override file to the correct location.  And since there was no folder standard, a module author could store their override files in any directory in the module that they wanted to. 

 

A module might also include overrides, but not want them installed automatically.  Perhaps there is an optional feature that requires an override, and if the merchant wants to use it, then they would need to manually install the overrides.  again in this case, the module author could put these files anywhere.

 

So if you are looking for overrides that were installed automatically, then just check for the overrides folder in the module. 

  • Like 2

Share this post


Link to post
Share on other sites

Bellini is right. Or in short words:

 

Before module installation, the override files can be anywhere.

After installation they are copied to the /override path into the corresponding directories.

  • Like 1

Share this post


Link to post
Share on other sites

It can by everywhere. But a good coder might use the same path structure within the modules path as prestashop uses in general. so the modules base path, /classes, /controllers, /override would be choices, following the sub path in these directories as well. But it's not fixed and accordidng to what I know there is also no directive from prestashop.

Share this post


Link to post
Share on other sites

As per the documentation Prestashop will look for the override files the module's folders /override/classes or /override/controllers. Usually Prestashop developers have their own module framework that could move the files accordingly. Don't get deceived!

Share this post


Link to post
Share on other sites

BTW - why don't you read the file ./cache/class_index.php ? There you should find all information on installed overrides.

Thank you for the suggestion.

 

It sounded like a good idea. Until I tested...

 

I made a copy of class_index.php. Then I enabled a module with overrides. But although class_index.php was regenerated its content stayed exactly the same. Also, it doesn't mention which module owns an override.

Edited by musicmaster (see edit history)

Share this post


Link to post
Share on other sites

  • 2 weeks later...
Hello

I just migrated my site to 1.6.1.16

One of my overrides (ProductSale.php) no longer works.

If I look at the contents of class_index.php I have this:


'ProductSaleCore' =>
  Array (
    'Path' => 'override/classes/ProductSale.php',
    'Type' => 'class',
    'Override' => false,

Is there a problem generating the file class_index.php ?

Thank you for your comeback.

Share this post


Link to post
Share on other sites

Another question: when you want to override a file in a module, should you copy the entire module into the override/modules directory or just the file whose contents you want to modify ?

Thank you again for your help.

Share this post


Link to post
Share on other sites

Is there a problem generating the file class_index.php ?

Thank you for your comeback.

Not that I am aware of.

 

Another question: when you want to override a file in a module, should you copy the entire module into the override/modules directory or just the file whose contents you want to modify ?

 

Typically we try to override with the minimum of changes and the minimum of code. If for example we have only one small function modified, we create an override only for this and not an entire class or module. If you copy all or many files or function, you don't see differences betweeen original setup and override without doing many file compares.

Share this post


Link to post
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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More