0

I've managed to make an extension for cashback feature in my opencart 3.0.3.2 .I've added the sql for creating a table in model , which i've executed(refer code please) through install() from controller.But in the front end while testing it says the table is not created. Please check and tell if I need any other additional requirements to be met. I've attached the code below.

<?php
model
  class ModelExtensionCmsCashback extends Model {
    public function install() {
      $this->db->query("CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "product_cashback` ( `cashback_id` INT NOT NULL AUTO_INCREMENT , `product_id` INT NULL , `status` TINYINT NOT NULL DEFAULT '1' , PRIMARY KEY (`cashback_id`)) ENGINE = InnoDB;");

  }

  public function uninstall() {
    $this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "product_cashback`");

}

}


<?php
  class ControllerExtensionModuleCashback extends Controller {
    private $error = array();

    public function index() {}

    public function validate() {}

    public function install() {
      $this->load->model('extension/cms/cashback');
      $this->model_extension_cms_cashback->install();
    }

    public function uninstall() {
      $this->load->model('extension/cms/cashback');
      $this->model_extension_cms_cashback->uninstall();
    }
  }
  • Seems that you have too much `}` in your model. Could you also be more specific about "*The problem I'm facing is regarding the table alteration for adding a column*" - what happens? what did you expect to happen? is there any error? – barbsan Aug 19 '19 at 07:41
  • @barbsan sorry, i've made the change. Can you help me through this problem? – Gowtham Chand Narayanan Aug 19 '19 at 12:43
  • You've previously manually deleted the table, right? I know it should be obvious, but we sometimes omit those little mistakes and make a world about the functions, while the solution was always something simple. – user3153340 Aug 26 '19 at 05:49

1 Answers1

0

You need to install those queries from extension>>modules and search in module section CmsCashback and press the plus sign (install button) next to it. It will execute sql queries and to run uninstall press minus sign

Zehra Noor
  • 121
  • 3