Jump to content

Recommended Posts

Hello guys,

 

recently i've wrote an article about 10+ common mistakes related to creating a PrestaShop module, you can read this article on PrestaShop Build blog here:

 

http://build.prestashop.com/howtos/module/Common-mistakes-while-coding-module/

 

PrestaShop has been around for many years, during which thousands of modules were made by thousands of developers, yet we still see the same simple mistakes being made, even though they could easily be avoided.

 

I'm open for a suggestions and discussion!

  • Like 4
Link to comment
Share on other sites

  • 2 months later...

Hi,

 

I really happy to see your article. It will help me a lot in future as well. :)

I am also creating module and got the same problem you mentioned.

 

Right now I am facing some Data validation related issues with my module. I don't know if this place is correct with this discussion.

 

Let me explain my problem :

 

I submitted my module and they said all ajax/cron must be validated with tokan. My problem is I have a link in admin config layout.

when I click that link I run ajax and redirect it to ajax.php in root of my module. My question is how do I pass security_key as you mentioned in your aritcle or

tokan to ajax file.

 

What I did for now is say :

url: '../modules/mymodule/ajax.php?token=xxxx',

 

in ajax url section and I checked in ajax.php file like :

if (Tools::getValue('token') != 'xxxx'
    || !Module::isInstalled('mymodule')) {
    die('Bad token');
}
 

 

I don't know if it is correct and Prestashop technical team reject this.

 

Please let me know your thoughts.

 

Thanks!

Link to comment
Share on other sites

  • 7 months later...

Hi,

 

Thanks for the tips! Some of them are really really helpful !

Can you also share, how you find the explanation of all these little things like:

 

$this->controllers = array(''); //loads the front controller

 

These properties are not explained in any tutorial nor the code comments. It only says : Load controllers.

So, I wonder : how can a novice developer get his way around the massive amounts of code?

 

Thanks for the tip!

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

  • 4 months later...
  • 5 months later...
On 2017/5/30 at 9:29 PM, vanhims said:

Hi,

 

Thanks for the tips! Some of them are really really helpful !

Can you also share, how you find the explanation of all these little things like:

 

$this->controllers = array(''); //loads the front controller

 

These properties are not explained in any tutorial nor the code comments. It only says : Load controllers.

So, I wonder : how can a novice developer get his way around the massive amounts of code?

 

Thanks for the tip!

If you configure a controller in your module in the array, when you install the module, Prestashop will install the controller for you automatically, please view the function installControllers in /class/module/Module.php file

Link to comment
Share on other sites

On 2017/10/6 at 6:50 PM, Lukenzo said:

Hello. Is there any way to access controller functions without making them static? For example I have a function in indexController and I want to access it in that template. PS 1.7

 

You can use $this->context->controller to invoke the function in the controller file in modules.

Link to comment
Share on other sites

  • 9 months later...
  • 3 weeks later...
On 1/6/2019 at 9:21 AM, dandumit said:

Sorry for this offtopic question : is there any guide for upgrading modules written in 1.6 to be compatible with 1.7 ?

I have 2 modules written by me and I intend to uprade to 1.7.

Thank you,

Daniel

Hey

what exactly you would like to know?

mostly it's front office who is affected by changes in PrestaShop 1.7, for example FO templates for controllers should extend page.tpl etc. you can't use {convertPrice} anymore, you don't have global variables like $link etc.

Link to comment
Share on other sites

  • 2 weeks later...
On 1/26/2019 at 3:27 AM, Krystian Podemski said:

Hey

what exactly you would like to know?

From local meetings I have understood that back-office has been migrated totally on symphony and therefore I have assumed that have changed all the objects and functions ... from your statement there is almost no change in backoffice...

Link to comment
Share on other sites

Oh, yes, indeed, PrestaShop back-office is now with some pages migrated to Symfony, you can read a lot about this migration here:

https://github.com/PrestaShop/prestafony-project
example module: https://github.com/PrestaShop/ps_linklist/tree/dev
https://devdocs.prestashop.com/1.7/development/architecture/migration-guide/
https://github.com/PrestaShop/PrestaShop/projects/3

Link to comment
Share on other sites

  • 11 months later...

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