Jump to content

which design pattern is used by prestashop


sicine

Recommended Posts

hello everyone

 

Can i know what design pattern prestashop team uses to develop this platform ? i'd like to know more about it and study it since it's the best way to be a good prestashop developer..  So if its possible to give me it name ... :lol:  

 

and thank you  :D

Link to comment
Share on other sites

OOoo thank you so much Bill :)  this is so much helpful..

 

So to sum up what i know, prestashop uses smarty as a template engine in the display level and the MVC design pattern in the organisation level(i just call it like that to help myself understanding thinks) ... Does it uses an other design pattern in any other level that i may not know ??

 

i'm a software engineer student and i'm in my learning way :unsure: ...  if its possible i'd like to have more clarifications on this or just some good links that will help me on that...     

 

and thank you :)

Link to comment
Share on other sites

That's about it. Basically in addition to the display functionality provide by Smarty in the TPL files. Positioning of elements and content are provided by CSS/Div and Hook positioning.

 

Prestashop defines most hooks you'll ever need but you can create new hooks and use them to assign content to a given area.

 

For example look to the Back office menu and in the Module section you'll see Positions. That is a quick way of moving things up and down. Look for your right or left column and you may move any of the items that live there. Or move something from the left column to the right.

 

Changing text is best done VIA the Translation tool located in the Localization section. You can change Almost all text for forms and modules for all installed languages. One of Prestashop' s strongest features.

  • Like 1
Link to comment
Share on other sites

Smarty is the V in MVC (Model View Controller).

The Classes are the M

The Controllers are, well the Controllers. 

 

However there is much more to the design of Prestashop (overrides, modules, hooks etc...) that really are not part of the MVC pattern, they are just additional design approaches for creating a dynamic and extendable application.

 

As for ORM, Prestashop does employ its own ORM system in the ObjectModel, which is what 99% of the classes extend from.  You should stick to using Prestashops object model when developing modules, and you can create your own that extend ObjectModel

  • Like 2
Link to comment
Share on other sites

First Of all i'm really thankful for your answers its helping me a lot. thank you Bellini :)  

 

so if i do understand very well if i want to create a module properly i need to stick to the ObjectModel ;   if for example there is anything that does not suite me on it, all i have to do is overriding that class or creating others that extends from it) then just working on my module.

 

developing properly is so impotent to me, so am I in the right way ?

 

       ps: excuse my English if there are any mistakes it's my 2nd language :unsure:    

Link to comment
Share on other sites

I would avoid extending existing classes (aka override) if you can, sometimes it is unavoidable, but if you can find another way to do it using hooks, that is the preference.

 

Two examples come to mind where you would override a Class

1) You want to add a new field to the ps_orders table.  For this, you would override the Orders class

2) The Orders class has a function, and you need to execute some logic during this function.  If this function does not execute any hooks, then you might need to override the function

 

Now if you are creating new functionality that requires new data to be stored in a new table, then you can create a new Class object that extends the ObjectModel.  Sometimes that is overkill since you can just write insert/select SQL statements directly.  Just use your judgement, and find what will be the easiest for you to maintain.

  • Like 1
Link to comment
Share on other sites

 

I would avoid extending existing classes (aka override) if you can, sometimes it is unavoidable, but if you can find another way to do it using hooks, that is the preference.

 

Two examples come to mind where you would override a Class

1) You want to add a new field to the ps_orders table.  For this, you would override the Orders class

2) The Orders class has a function, and you need to execute some logic during this function.  If this function does not execute any hooks, then you might need to override the function

 

Now if you are creating new functionality that requires new data to be stored in a new table, then you can create a new Class object that extends the ObjectModel.  Sometimes that is overkill since you can just write insert/select SQL statements directly.  Just use your judgement, and find what will be the easiest for you to maintain

 

 

Okey, got it ^_^,  now i have a clear idea about how doing it,  thank you so much  again it's been so much helpful :D  

Link to comment
Share on other sites

  • 3 years later...

Hello @sicine,

I think that the only design pattern that was mentioned here is the MVC, but I can see that the Singleton design pattern is used as well in e.g.: DB class and Cache class, I think there's also the Adapter design pattern as I could see it in the latest versions of Ps 1.6.x in Adapter folder.

 

I hope this helps you :)

 

Cheers

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...