Search code examples
moduleoverridingprestashopprestashop-1.7

Prestashop 1.7.x module architecture done right, how to?


I created 2 modules, both using an override on the same class ( Customer ) to add DB extra data representation. The second module gives me an error because the class is overridden already by the first module. Both modules have an "/override/classes/" path. I solved merging all the overrides on the first module and stripping it out form the second.

But what is the right way to proceed before coding a module that uses an override?

  1. should I manage all needed overrides putting them in the "/override" folder in the filesystem, stripping out override from the modules folder?
  2. should I create a module that manages all the classes override, stripping out override from the other modules folder?
  3. or ... what?

Thank you in advance for your indications. My best, Daniele M


Solution

  • Indeed all depends on your needs:

    • If you have needs on the same override, but not the same function, then this will not be a problem
    • If you have needs on the same override but on the same function, then indeed you must combine them in one

    In any case, try to favor Hooks, more than overides, this is cleaner and creates less hassle during installation.

    cordially