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 2

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
Share on other sites

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

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

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