Jump to content

General development BCPs


papaja

Recommended Posts

Hello everyone,

I am just starting to get my feet wet with PS development. I would like to learn to do it right or best way from beginning, so I have few general questions.

 

Let's say that I want to collect email addresses of newsletter subscribers from my PS and send them using web services to our other software. I want everything in PS to continue working pretty much as it is working now which means user can subscribe using newsletter block in the footer or subscribe/unsubscribe while creating/modifying account.

 

In order to capture these two events, should I modify newsletter block module and account creation/modification logic or should I create a separate module and somehow hook it into these events or something else?

 

If I create my own module I would also like it to show pop-in to some visitors asking for newsletter subscription. I want to say that module will have some html and css for the front end.

 

If I use module which has html and css for front office, can that module be hooked into events of other modules or should I create 2 modules: one for collecting emails (visual) and another for hooking into every place where emails are collected (non visual :))?

Link to comment
Share on other sites

Hello Papaja,

Good questions.

 

 

 

In order to capture these two events, should I modify newsletter block module and account creation/modification logic or should I create a separate module and somehow hook it into these events or something else?

You should create a module and hook into these events. I believe you know which hooks to work with.

 

 

 

If I use module which has html and css for front office, can that module be hooked into events of other modules or should I create 2 modules: one for collecting emails (visual) and another for hooking into every place where emails are collected (non visual  :))?

Only 1 module is enough.

Please be noticed that, relationship between module and hook is 1-many. It means, 1 module can handle more than 1 hook.

Further more, there are 3 kinds of hook.

- Hooks for frontend (which you are referring as css/html...): usually start with "displayAbc"

- Hooks for controller level: usually start with "actionXyz"

- Hooks for model level such as "afterProductUpdate", "beforeCreateAccount", etc..

Anyway, I don't see the big differences between (2) and (3).

 

Hope this helps!

Tung

Link to comment
Share on other sites

prestashop by default hasn't got action / display hooks inside other modules.

if i were you - i will do everything in one module.

- display hooks to display html+css form (behind this form, inside php file create code to save newsletter informations)

- controller to get informations about subscriptions, and to send them to external service in accepted by service format

  • Like 1
Link to comment
Share on other sites

Thank you Tung, Vekia.

 

As I dived deeper into my module development and checked newsletter block module I have realized that what I really need is newsletter block module on some steroids :) For example I need First name and Last name as columns in db table. And Vekia clarified that Module like newsletter block does not have hooks.

 

So, should I:

- create new module using newsletter block as starting point or

- modify newsletter block module?

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