PrestaShop Forum

The best place in the world to ask questions about PrestaShop and get advice from our passionate community!

PrestaShop Forum

Jump to content

how to create a new module? any kind!

7 replies to this topic
#1
FireDog

    PrestaShop Apprentice

  • Members
  • PipPip
  • 43 posts
Hi if anybody there know how to create a new module for prestashop please explain here or leave a tutorial adress...

i want to create a new payment module, cause in brazil, prestashop payments modules doesn't work, paypal doesn't have our currency. :/

waiting for suggestions.

thx

#2
By Kuhi

    PrestaShop Apprentice

  • Members
  • PipPip
  • 86 posts
Are Oscommerce modulles to adjust Prestashop ?

Please ....?
www.presta-tr.com

#3
Paul C

    PrestaShop Fanatic

  • Members
  • PipPipPipPip
  • 1004 posts
The answer is that it's either very easy to do (if you're used to programming in PHP using objects and classes) or very difficult!

The best way to learn is to take one of the simpler modules and play with the basic code until you understand the basics of how it works. You don;t need much code for a "minimal" implementation.

It terms of porting osCommerce code..... it's almost entirely a different thing, except in terms of payment modules where certain blocks of code could be easily re-used.

Paul
Free Prestashop modules and developer resources

Latest Prestashop Developer articles:
* 1.4 Plugins Revisited – Part 1
* 1.4 Plugins Revisited – Part 2

Latest News:
Prestashop Module and Theme Developers can now Advertise on eCartService.net

#4
davadda

    PrestaShop Newbie

  • Members
  • Pip
  • 5 posts
And if I don't want to re-use any existent module but create an own one from the scratch?
What are the basics for creating modules? What do I have to mind to, if I create a module?

Are there any Tutorials or faqs regarding to that that topic?

Thanks for your help.
davadda

#5
Paul C

    PrestaShop Fanatic

  • Members
  • PipPipPipPip
  • 1004 posts
Well the most basic one (non payment):


<?php

class mymodule extends Module {


}

?>


Not sure what you're asking apart from that?? :)

Paul
Free Prestashop modules and developer resources

Latest Prestashop Developer articles:
* 1.4 Plugins Revisited – Part 1
* 1.4 Plugins Revisited – Part 2

Latest News:
Prestashop Module and Theme Developers can now Advertise on eCartService.net

#6
davadda

    PrestaShop Newbie

  • Members
  • Pip
  • 5 posts
Thanks for your quick answer. The code you submitted was my first idea, but it does not work.


class test extends Module
{
public function __construct()
{
$this->name = 'test';
$this->tab = 'Tools';
$this->version = "0.1";

parent::__construct();

/* The parent construct is required for translations */
$this->page = basename(__FILE__, '.php');
$this->displayName = $this->l('Test');
$this->description = $this->l('Just a test!');
}
}


Thats my code, but it does not get listed in the modules list. Any idea?

(If I change the name of the google adsense Module for example it works - the name changes in the modules list - but if I change the folder name it is not listed anymore. Is there any Config that I have to edit?)

#7
Paul C

    PrestaShop Fanatic

  • Members
  • PipPipPipPip
  • 1004 posts
OK, create a file containing the following, and call it test.php.


<?php
class test extends Module
{
public function __construct()
{
$this->name = 'test';
$this->tab = 'Tools';
$this->version = "0.1";

parent::__construct();

/* The parent construct is required for translations */
$this->page = basename(__FILE__, '.php');
$this->displayName = $this->l('Test');
$this->description = $this->l('Just a test!');
}

function install()
{
if (!parent::install())
return false;

return true;
}

}
?>


Make a directory /modules/test and put the above file in it, and it should show up in the back office :)

The $this->name member variable must match the directory and filename (case sensitive). The Class name must also match, but isn't case sensitive.

Paul
Free Prestashop modules and developer resources

Latest Prestashop Developer articles:
* 1.4 Plugins Revisited – Part 1
* 1.4 Plugins Revisited – Part 2

Latest News:
Prestashop Module and Theme Developers can now Advertise on eCartService.net

#8
davadda

    PrestaShop Newbie

  • Members
  • Pip
  • 5 posts
Thank you very much. I found that out about some minutes ago.
A short faq about that would make it easier to create the first module :D