How To Create Your First Module On PrestaShop 1.16 - Amigoways

by Amigoways Technologies Pvt Ltd on Jun 9, 2023 Ecommerce 334 Views

How To Create Your First Module On PrestaShop 1.16

Amigoways Explain how to create your first module on PrestaShop with these easy step-by-step instructions.

We need to create our module’s folder in the folder modules which is located in the root folder. The modules folder contains all the PrestaShop modules. All basic modules will be found here.

The folder structure will be shown below.

prestashop-folder

If the module folder name is newmodule, it should have a file name called newmodule.php.

The index is the starting file of the module.

In the  newmodule.php  file, you must create a constructor to have basic info such as compatibility, name, author and displayName. The format is as follows.

if (!defined('_PS_VERSION_'))

exit();

class Newmodule extends Module
{

public function __construct()

{

$this->name = ‘New Module’;

$this->tab = ”;

$this->version = ‘1.0.0’;

$this->author = ‘Amigoways Technologies’;

$this->need_instance = 1;

$this->ps_versions_compliancy = array(‘min’ => ‘1.7.1.0’, ‘max’ => _PS_VERSION_);

$this->bootstrap = true;

parent::__construct();

$this->displayName = ‘New Module’;

$this->description = ‘This module is a sample module.’;

$this->confirmUninstall = $this->l(‘Are you sure you want to uninstall?’, ‘newmodule’);

}

}

Then install & uninstall. functions to run the to-do function when the module is installed / uninstalled.

public function install()

{

//to do code

return parent::install() && $this->registerHook(‘hook_function_name’) ;

}

public function uninstall()

{

//to do code

if (!parent::uninstall() || !Configuration::deleteByName(‘newmodule’))

return false;

return true;

}

For eg., To display the content on the home page, the function name is like hookDisplayHome. hookDisplay is a hook to assist your code to the PrestaShop events.

public function hookDisplayHome($params)

{

$this->context->smarty->assign(

array(‘param’ => value )

);

return $this->display(__FILE__, module:newmodule/views/templates/hook/filename.tpl);

}

To load the view file,

$this->display(__FILE__, module:newmodule/views/templates/hook/filename.tpl)

To have the configuration settings for the admin, the function getContent is used to exist.

public function getContent()

{

$fields_form[0][‘form’] = array( ‘legend’ => array( ‘title’ => $this->l(‘New Module’), ),

‘input’ => array( array( ‘type’ => ‘text’, ‘label’ => $this->l(‘title’), ‘name’ => ‘title’, ‘lang’ => true, ‘size’ => 20, ‘required’ => true ), ),

‘submit’ => array( ‘title’ => $this->l(‘Save’), ‘class’ => ‘btn btn-default pull-right’ )

); $helper = new HelperForm();

$helper->module = $this;

$helper->name_controller = $this->name;

$helper->token = Tools::getAdminTokenLite(‘AdminModules’);

$helper->currentIndex = AdminController::$currentIndex.’&configure=’.$this->name;

$helper->title = $this->displayName;

$helper->show_toolbar = true; // false -> remove toolbar

$helper->toolbar_scroll = true; // yes – > Toolbar is always visible on the top of the screen.

$helper->submit_action = ‘submit’.$this->name;

$helper->toolbar_btn = array( ‘save’ => array( ‘desc’ => $this->l(‘Save’), ‘href’ => AdminController::$currentIndex.’&configure=’.$this->name.’&save’.$this->name. ‘&token=’.Tools::getAdminTokenLite(‘AdminModules’), ), ‘back’ => array( ‘href’ => AdminController::$currentIndex.’&token=’.Tools::getAdminTokenLite(‘AdminModules’), ‘desc’ => $this->l(‘Back to list’) ) );

// < load current value > $helper->fields_value[‘title’] = Configuration::get(‘title’);

return $helper->generateForm($fields_form);

}

Conclusion

Amigoways regularly publishes tutorial blog posts on Module & Plugin development. Stay in touch with them for the latest updates and to learn more about building advanced modules.

Learn how to create your first module on PrestaShop 1.16 ???????? ???? https://www.amigoways.com/blog/how-to-create-your-first-module-on-prestashop-1-16/

Tag: PrestaShop, guide of PrestaShop module, module guide, PrestaShop guide

 

Article source: https://article-realm.com/article/Internet-Business/Ecommerce/46098-How-To-Create-Your-First-Module-On-PrestaShop-1-16-Amigoways.html

Comments

No comments have been left here yet. Be the first who will do it.
Safety

captchaPlease input letters you see on the image.
Click on image to redraw.

Reviews

Guest

Overall Rating:

Statistics

Members
Members: 17183
Publishing
Articles: 79,719
Categories: 202
Online
Active Users: 1715
Members: 8
Guests: 1707
Bots: 13870
Visits last 24h (live): 5003
Visits last 24h (bots): 53088

Latest Comments

This is also a very good post which I really enjoyed reading. It is not every day that I have the possibility to see something like this..  zonahoki28    
Bài viết cung cấp góc nhìn đáng chú ý về việc triển khai các chương trình phúc lợi xã hội của Chandrababu Naidu. Những chính sách hướng đến cải thiện đời sống người dân luôn là chủ đề đáng quan...
Bài viết mang đến góc nhìn đáng chú ý về việc triển khai các chương trình phúc lợi và tác động của chúng đối với cộng đồng. Mình nghĩ những chính sách hướng đến cải thiện đời sống người dân luôn...
What a blog. Lovely stuff.
on Oct 11, 2026 about The Latest Online Business
What a blog. Lovely stuff.
on Oct 11, 2026 about The Latest Online Business
Bài viết mang đến góc nhìn thú vị về các chương trình phúc lợi của Chandrababu Naidu và những tác động đối với đời sống người dân. Mình đánh giá cao những chính sách hướng đến cải thiện giáo dục,...
An unexpected evening spent with a Bhopal Escorts Service revealed new facets of desire. The atmosphere was relaxed, while the physical connection deepened with every passing moment. Soft...
We believe comfort is the gateway to real excitement. An Okhla Escort Service offers companions who prioritize your happiness. Our team creates space for fantasy to unfold and pleasure to...
Bài viết cung cấp góc nhìn khá thú vị về việc triển khai các chương trình phúc lợi, đặc biệt qua những thông tin cụ thể và cách tiếp cận thực tế. Nội dung giúp người đọc có thêm cơ sở để tìm hiểu...
Slope 2 represents a fascinating shift in how games keep us engaged. Instead of managing inventory or hiring staff, you're navigating a constantly shifting environment where the rules stay...

Translate To: