Jump to content

Custom Module doesn't update


xSmog3s

Recommended Posts

Hi, 

I'm a new prestashop user, I trying to learn how to create an ecommerce website and currently I'm working on my first custom module. It's a simple "hello world" that has to be displayed in my homepage. I used MAMP and every time I start working on my project I use the command  npm run watch in the _dev folder so the css/html/etc. gets updated or uploaded. 

I created a folder inside modules called mymodule. Inside the folder mymodule I created a file mymodule.php. 

<?php
if (!defined('_PS_VERSION_')) {
    exit;
}
class MyModule extends Module
{
    public function __construct()
    {
        $this->name = 'mymodule';
        $this->tab = 'front_office_features';
        $this->version = '1.0.0';
        $this->author = 'Firstname Lastname';
        $this->need_instance = 0;
        $this->ps_versions_compliancy = [
            'min' => '1.6',
            'max' => _PS_VERSION_
        ];
        $this->bootstrap = true;

        parent::__construct();

        $this->displayName = $this->l('My module');
        $this->description = $this->l('Description of my module.');
    }
    public function install()
    {
        if(
            !parent::install() OR
            $this->registerHook('displayHome')
            )
            return FALSE;
        return TRUE;
    }
    public function hookDisplayHome($params)
    {
        return 'Hello World';
    }
}
?>

When I go look in Module -> Module Manager I can't find mymodule so I have to go in Module Manager -> Upload Module and in this way the I can install it. The problem is that whenever I make a change in my php file and for example instead of returning "Hello World" I return "Hello Forum"  the change is not displayed in my website. 

I cleared the cache in my browser but still the message remains "Hello World". I think the problem is because I'm not compiling the modules folder like I do with my _dev folder (npm run watch). Do you know if there is a script that automatically checks for updates in my modules folder and compile them. Thanks

Link to comment
Share on other sites

I found a solution:

I'm using a child theme of the prestashop basic theme. I thought that my custom module had to go in the child theme module's folder and that's the reason why they were not showing up in the module catalog. I had to move them into the parent theme modules folder and now they show up in the catalog and can edit the code.  

 

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