Jump to content

Problem using Install and Uninstall functions


jphuttun

Recommended Posts

Hi!

I have a problem adding correctly my selfmade module to Prestashop. I manage to add it by using "Add a module from my computer" ability in backoffice "Modules" tab (my development prestashop version is 1.4.0.14).

In my module (that inherited from Module class), I have Install function. Install function calls my own "public function installExtension" using command $this->installExtension().

installExtension function adds 2 fields to MySQL database. I have tested that my installExtension function works. But when I try adding my module through "Add a module from my computer", it doesn't execute my installExtension function and add fields in database. If I add those fields manually, module works fine. With Uninstall function I have similar problem, but it should drop those fields when deleting module (and nothing happens).

So, is Install function called when adding a new module or should I use some other function?

I also tried to add my module to prestashop version 1.2.2.0, but in that case the whole module tab doesn't work anymore. What kind of changes have happened regarding adding modules? The actual shop is version 1.3.5.0, so is adding modules in 1.3.5.0 more similar to versions 1.4 or 1.2 (is installing a module in version 1.3.5.0 safe if it causes problems in version 1.2)?

Link to comment
Share on other sites

I found the problem!

The problem was that I called my own function before I called parent::install() or parent::uninstall() function.

When I switch the functions place in code, module starts acting correctly.

Thanks for valuable advice! :-)

Link to comment
Share on other sites


Off the top of my head... why are you writing a custom "myVeryMostBestestInstall" method?


I made this method, because it was easier to test. Inside the method, there was test if these 2 additional fields were already installed and if not, method adds those fields to database. Because I couldn't get the install method work properly, my module executed my own install method always when I was entering the module. At first the code was inside the install method, but install method also calls registerHook and parent::install functions, so I divided those to separate methods.
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...