Book Image

PrestaShop Module Development

By : Serny
Book Image

PrestaShop Module Development

By: Serny

Overview of this book

If you are a developer who is new to PrestaShop and wants to get a good foundation in development on the PrestaShop framework, this book is for you. It's assumed that you will have some experience with PHP5, jQuery, and HTML/CSS (no need to be an expert on it).
Table of Contents (13 chapters)
12
Index

Deleting a table on uninstallation


The uninstall method is pretty much constructed the same way as the install method.

First, create an uninstall.sql file in the install directory of your module in which you will write the following SQL command to drop the mymod_comment table:

DROP TABLE `PREFIX_mymod_comment`;

Next, in mymodcomment.php, write an uninstall method to do the following:

  • Call the uninstall parent method

  • Load the uninstall.sql file

  • Check the return values

We will also delete the configuration values MYMOD_GRADES and MYMOD_COMMENTS. It isn't mandatory but it's cleaner that way.

At the end, you should have something like this:

public function uninstall()
{
  // Call uninstall parent method
  if (!parent::uninstall())
    return false;

  // Execute module install SQL statements
  $sql_file = dirname(__FILE__).'/install/uninstall.sql';
  if (!$this->loadSQLFile($sql_file))
    return false;

  // Delete configuration values
  Configuration::deleteByName('MYMOD_GRADES');
  Configuration...